VB Help If first char of a string <> Numurical

Get help on programming - C++, Java, Delphi, etc.
Post Reply
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

VB Help If first char of a string <> Numurical

Post by SBSP »

Hi I need help.

I wrote a macro in Excel that picks up fields
but need to filter out cells that does not start with a Number.

Instead of

If mid(Cell,1,1) <> "1" then ect
If mid(Cell,1,1) <> "2" then ect
If mid(Cell,1,1) <> "3" then ect
If mid(Cell,1,1) <> "3" then ect
If mid(Cell,1,1) <> "4" then ect

I need a syntax command


Code: Select all

Dim CellCount as long
CellCount  = 1
Do:DoEvents

If mid(Cell,1,1) <> Number Char then 
Goto Skip

End if

Skip:
Cellcount = Cellcount +1
loop
end if
anyone ?
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

<hint>
what is the ascii value of '0'...?

what is the ascii value of '9'...?
</hint>
Most people would sooner die than think; in fact, they do so - Bertrand Russel
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

Okay you wana make me work hey1 :twisted:

Code: Select all

If asc(mid(Cell,1,1)) is between 0 to 11 then
Do what ever 
?
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

ASCII '0' == 48
ASCII '9' == 57


the char datatype is simply a special type of int... so you can check for a value between '0' and '9' or 48 and 57...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

rustypup wrote:ASCII '0' == 48
ASCII '9' == 57


the char datatype is simply a special type of int... so you can check for a value between '0' and '9' or 48 and 57...
Lol I used http://www.asciitable.com/
read it wrong
Post Reply