Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

error come out when i using InStr

Posted on 2006-06-10
7
Medium Priority
?
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

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.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

670 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