Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why is this a number?
Hi
I'm using VBA 6.3 If I pass 45- to this: If IsNumeric(OffsetNo) = False Then ... it returns True. 1) Why? 2) How do I prevent this happening? Thanks in Advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why is this a number?
Because Excel knows how to convert it to a number
? clng("45-") -45 which is the defninition of isNumeric. Many accounting applications indicate negatives by using the notation you show. -- Regards, Tom Ogilvy "Dave F." wrote in message ... Hi I'm using VBA 6.3 If I pass 45- to this: If IsNumeric(OffsetNo) = False Then ... it returns True. 1) Why? 2) How do I prevent this happening? Thanks in Advance. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why is this a number?
Thanks for replying.
I'm running this within AutoCAD & don't have the Office Reference ticked. I'm confused why it would be a specific Excel problem. Isn't IsNumeric a general VB command? Is there a way to prevent it happening? I'm trying to allow only positive numeric values being typed & displayed in a textbox: If IsNumeric(OffsetNo) = False Then ' if there is a value in the textbox & it's not a number OffsetNo = Left$(OffsetNo, Len(OffsetNo) - 1) ' remove last typed TxtBx_Dist.Value = OffsetNo ' & put it back in the box End If Cheers Dave F. "Tom Ogilvy" wrote in message ... Because Excel knows how to convert it to a number ? clng("45-") -45 which is the defninition of isNumeric. Many accounting applications indicate negatives by using the notation you show. -- Regards, Tom Ogilvy "Dave F." wrote in message ... Hi I'm using VBA 6.3 If I pass 45- to this: If IsNumeric(OffsetNo) = False Then ... it returns True. 1) Why? 2) How do I prevent this happening? Thanks in Advance. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why is this a number?
I don't recall saying it is a specific Excel problem - Perhaps I should have
said VBA rather than Excel. Neither clng or IsNumeric are unique to excel. If you want to check for a hypen as the last character, then check if a hypen is the last character. Another approach might be if isnumeric(string) then if clng(string) < 0 then -- Regards, Tom Ogilvy "Dave F." wrote in message ... Thanks for replying. I'm running this within AutoCAD & don't have the Office Reference ticked. I'm confused why it would be a specific Excel problem. Isn't IsNumeric a general VB command? Is there a way to prevent it happening? I'm trying to allow only positive numeric values being typed & displayed in a textbox: If IsNumeric(OffsetNo) = False Then ' if there is a value in the textbox & it's not a number OffsetNo = Left$(OffsetNo, Len(OffsetNo) - 1) ' remove last typed TxtBx_Dist.Value = OffsetNo ' & put it back in the box End If Cheers Dave F. "Tom Ogilvy" wrote in message ... Because Excel knows how to convert it to a number ? clng("45-") -45 which is the defninition of isNumeric. Many accounting applications indicate negatives by using the notation you show. -- Regards, Tom Ogilvy "Dave F." wrote in message ... Hi I'm using VBA 6.3 If I pass 45- to this: If IsNumeric(OffsetNo) = False Then ... it returns True. 1) Why? 2) How do I prevent this happening? Thanks in Advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sumif number is greater than a number but less than another number | Excel Discussion (Misc queries) | |||
How can I click on a telephone number in an Excel 2002 spreadsheet, and have the number dialed? | Excel Discussion (Misc queries) | |||
How to calculate number of occurencies of a specific number number | Excel Discussion (Misc queries) | |||
countif formula to find the occurances of a number that is greater than one number but less than another | Excel Discussion (Misc queries) | |||
Rounding a number to a multiple quantity that adds to a fixed total number | Excel Worksheet Functions |