Converting V6 Format to VB.net

G

Guest

Hello
I am trying to convert the following statement to from Vb6 to VB.Net but
with no luck. Can anyone tell me what would be an equivalent of this format
statement would be in vb.net?


For indx = 0 To SendLen - 1
tmpStr = tmpStr & Format(Hex(SendBuff(indx)), "00") & " "
Next indx


Thanks so much

AL
 
L

Larry Serflaten

Al said:
Hello
I am trying to convert the following statement to from Vb6 to VB.Net but
with no luck. Can anyone tell me what would be an equivalent of this format
statement would be in vb.net?


For indx = 0 To SendLen - 1
tmpStr = tmpStr & Format(Hex(SendBuff(indx)), "00") & " "
Next indx


In .Net the StringBuilder class is more performant, requiring fewer objects
to be created, when concatenating text:

Dim data As Integer() = New Integer() {5, 10, 15, 20, 25, 30}
Dim msg As New System.Text.StringBuilder
Dim text As String

For idx As Integer = 0 To data.GetUpperBound(0)
text = Hex(data(idx)).PadLeft(2, "0"c)
msg.Append(text)
msg.Append(" ")
Next

MsgBox(msg.ToString)




HTH
LFS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top