VB automaticallying casting?

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

I get a casting error when I try to do this.. I would like the variable to
stay a string

Dim userinfo As String = "5.0.2456.4343"

Dim buserinfo As String

buserinfo = userinfo.Substring(userinfo - 8)
 
Microsoft said:
I get a casting error when I try to do this.. I would like the variable to
stay a string

Dim userinfo As String = "5.0.2456.4343"

Dim buserinfo As String

buserinfo = userinfo.Substring(userinfo - 8)

1. Turn Option Strict On

2. buserinfo = userinfo.Substring(0, userinfo.Length - 8)

Cheers

Arne Janning
 
* "Microsoft said:
I get a casting error when I try to do this.. I would like the variable to
stay a string

Dim userinfo As String = "5.0.2456.4343"

Dim buserinfo As String

buserinfo = userinfo.Substring(userinfo - 8)

'userinfo' is a 'String', so it's not possible to subtract 8 from the
string. Maybe you want to use 'userinfo.Length' which will return the
length of the string.
 
Back
Top