converting VB6 to vb.net

B

Brian

for some reason I can not get this to work.. but there is something
different about it...
OffSet in both peices = 4812
VB 6 CODE:
Const Sch As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZab"
ShiftCode = Mid$(Sch, (OffSet Mod 28) + 1, 1)

this function returns RYDK which is correct..

VB.Net 2005 Code:
Const Sch As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZab"

Return Sch.Substring((OffSet Mod 28) + 1, 1)

returns SZEL

Why is there a differance? what am i missing?
 
S

Stephany Young

The index (first parameter) for the String.SubString() method is zero based,
so it should be:

Return Sch.Substring(OffSet Mod 28, 1)
 
B

Bill McCarthy

Brian said:
for some reason I can not get this to work.. but there is something
different about it...
OffSet in both peices = 4812
VB 6 CODE:
Const Sch As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZab"
ShiftCode = Mid$(Sch, (OffSet Mod 28) + 1, 1)

this function returns RYDK which is correct..



Really ? Here it returns Y which is what I would expect.

VB.Net 2005 Code:
Const Sch As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZab"

Return Sch.Substring((OffSet Mod 28) + 1, 1)

returns SZEL

Why is there a differance? what am i missing?

Well considering both Mid and SubString with the last parameter as 1 only
return a single character, I'd say you are missing code that does as you
described in either VB6 or Vb.NEt ;)
 
B

Brian

That seems to be it.. thanks

Stephany Young said:
The index (first parameter) for the String.SubString() method is zero
based, so it should be:

Return Sch.Substring(OffSet Mod 28, 1)
 

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