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 70

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' ??
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hbo knew my windows software 4 75
Iteration Help ( VB) 5 35
Finding the IIS version 5 37
Securing WEBAPI on Azure 2 18
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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