Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

error come out when i using InStr

Posted on 2006-06-10
7
Medium Priority
?
235 Views
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.

0
Comment
Question by:kengkit
7 Comments
 
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.

Try:

        Dim test As String = "BB1234/34"
        Dim newString As String = test.Substring(0, InStr(test, "/") - 1)
0
 
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("/"))

Cheers!
0
 

Author Comment

by:kengkit
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' ??
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 33

Expert Comment

by:hongjun
ID: 16879455
Then try this

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

Accepted Solution

by:
hongjun earned 100 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.


hongjun
0
 

Author Comment

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

Expert Comment

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net 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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

972 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