Solved

Determine if the second character in a string is a number

Posted on 2006-07-23
3
170 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
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 68
VBA error replacing data 6 41
I need help embedding an image as HTML in my vb.net application 3 79
Export Data to Different .csv Files 26 121
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 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