Question

I am using old code from vb but I would like to know whats the best approach for vb.net new code..

test = Mid(strData, Pos1 + Len(strFirst))
test = Mid(strData, Pos1 + Len(strFirst) + 3 + Len(strID))
test = Microsoft.VisualBasic.Left(strID, Pos2 - 1)
Was it helpful?

Solution

Since you are not supplying the data contents of variables: strData strID strFirst Pos1 Pos2 I can't write a better code to explain, but this example should be sufficient.

Equivalent of VB6 functions:

Len  = "String".Length
Left = "String".Substring(0, length)
Mid  = "String".Substring(start position, length)

Then VB.NET code translation should looks like this:

test = strData.Substring(pos1 + strFirst.length)
test = strData.Substring(pos1 + strFirst.length + 3 + strID.length)
test = strID.Substring(Pos2 - 1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top