[RESOLVED] How to differentiate bet a number and a character ??
Hey guys!
I wanted to know if there is a ISNUM kind of a command which can be used to differentiate between a number and a character..
Actually, i will be having two kinds of STRINGS in excel.
1) \\<Characters>\\ example: \\DELCHARNUM\\
2) \\<Numbers>\\ example: \\1\\
Now depending on wheather the string is of the first type or the second, ill have to carry out certain actions.. so i just wanted to know how i could differentiate bet the two kinds of Strings shown above..
Cheers
Abhilash
Re: How to differentiate bet a number and a character ??
Re: How to differentiate bet a number and a character ??
hey sid!
that thread did help.. as in i found bout the IsNumeric func. that shd solve my prob but another thing i require is to get to the number or the character..
I say that because.. in the excel sheet, there can be normal character strings which have to be treated separately and then there will be strings starting wid 2 backslashes ( \\ ).
So basically, i first have to chk for the 2 backslashes and then chk if the next character after the 2 backslashes is a number or a character.
I can use the IsNumeric once i have gone past the 2 backslashes.. but i dun rilli know how to do dat...
Please advise
cheers
Abhilash
Re: How to differentiate bet a number and a character ??
Quote:
once i have gone past the 2 backslashes.. but i dun rilli know how to do dat...
Then the MID or the INSTR function will help you.
Try them...
here is a quick example. Edit it as per your needs.
vb Code:
Private Sub CommandButton1_Click()
strng = "//1//"
'or strng = "ads/as//2//sdfa"
For i = 1 To Len(strng)
If Mid(strng, i, 2) = "//" Then
Count = i + 2
Exit For
End If
Next i
If IsNumeric(Mid(strng, Count, 1)) = True Then
MsgBox Mid(strng, Count, 1) & " is a number"
End If
End Sub
Re: How to differentiate bet a number and a character ??
Hey Koolsid!!
This looks like wad i need.. thx
cheers
Abhilash