Solved

Determine if the second character in a string is a number

Posted on 2006-07-23
3
171 Views
Last Modified: 2010-04-30
I am using VB6 and I need a way to determine if the second character in a string is a variable.  I found the following code:

result = (isnumber(Value(Left(myString, 2))))

There were no functions listed with this code so I thought it was using functions build into VB6, but it must not be the case because it does not work.

Does anyone know an easy way to determine if the second character in a string is a number?
0
Comment
Question by:bpl5000
[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
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 17165049
Hi bpl5000,

If IsNumeric(Mid(myString, 2, 1)) Then
    'action for is a numeral
Else
    'action for not a numeral
End If

Regards,

Patrick
0
 
LVL 5

Author Comment

by:bpl5000
ID: 17165137
Thanks Patrick!  This works great, but I thought Left would be the way to go.  Looks like I'm wrong (again... D'oh!).  I guess if I say "If IsNumeric(Left(myString, 2)) Then"... this is looking at the first 2 characters instead of only the second character?
0
 
LVL 5

Author Comment

by:bpl5000
ID: 17165159
No need to answer that question my last question... I tried:

MsgBox Left(myString, 2)

and now I see it does give you the first two digits.
0

Featured Post

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!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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