error come out when i using InStr

Dim test As String = "BB1234/34"
Dim newstring As String = Left(test, InStr(test, "/") -1)

the following error message come out when the above code is used... why?

Compiler Error Message: BC30471: Expression is not an array or a method, and cannot have an argument list.

kengkitAsked:
Who is Participating?
 
hongjunCommented:
But then actually, your original example request for output "BB1234".
So I would suggest you DON'T award points to me.


hongjun
0
 
Carl TawnSystems and Integration DeveloperCommented:
Left() in VB.Net is for setting the left edge of a control, its not the same as Left in VB6.

Try:

        Dim test As String = "BB1234/34"
        Dim newString As String = test.Substring(0, InStr(test, "/") - 1)
0
 
Éric MoreauSenior .Net ConsultantCommented:
Hi kengkit,

You should use the .Net methods:

        Dim test As String = "BB1234/34"
        Dim newstring As String = test.Substring(0, test.IndexOf("/"))

Cheers!
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
kengkitAuthor Commented:
Hi emoreau

if i using ur method.. the result return is 'BB1234' but not '34'

wat to do if i gonna get '34' ??
0
 
hongjunCommented:
Then try this

Dim test As String = "BB1234/34"
Dim newstring As String = test.Substring(test.IndexOf("/") + 1)
0
 
kengkitAuthor Commented:
honjun.. u got the point!!  becoz wat i request for is not "BB1234"
0
 
hongjunCommented:
Got the points but with a C grade?
Please explain.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.