error come out when i using InStr

Posted on 2006-06-10
Last Modified: 2012-06-21
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.

Question by:kengkit
LVL 52

Expert Comment

by:Carl Tawn
ID: 16877658
Left() in VB.Net is for setting the left edge of a control, its not the same as Left in VB6.


        Dim test As String = "BB1234/34"
        Dim newString As String = test.Substring(0, InStr(test, "/") - 1)
LVL 69

Expert Comment

by:Éric Moreau
ID: 16877671
Hi kengkit,

You should use the .Net methods:

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


Author Comment

ID: 16879446
Hi emoreau

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

wat to do if i gonna get '34' ??
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

LVL 33

Expert Comment

ID: 16879455
Then try this

Dim test As String = "BB1234/34"
Dim newstring As String = test.Substring(test.IndexOf("/") + 1)
LVL 33

Accepted Solution

hongjun earned 50 total points
ID: 16879458
But then actually, your original example request for output "BB1234".
So I would suggest you DON'T award points to me.


Author Comment

ID: 16879769
honjun.. u got the point!!  becoz wat i request for is not "BB1234"
LVL 33

Expert Comment

ID: 16879989
Got the points but with a C grade?
Please explain.

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now