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.
 

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

Back
Top