Regarding long data type ..
-
Code is- If Text3.Text > 42949672945 Then MsgBox "Should be between 0 to 4294967295" When I save it, a # is added to the 42949672945 and code becomes like this- If Text3.Text > 42949672945# Then MsgBox "Should be between 0 to 4294967295" Text3 is a simple data type whose format is Number. It is the problem of data type that VB does not support.? Plz guide me what may be the problem????? Thanks in adv...
-
Code is- If Text3.Text > 42949672945 Then MsgBox "Should be between 0 to 4294967295" When I save it, a # is added to the 42949672945 and code becomes like this- If Text3.Text > 42949672945# Then MsgBox "Should be between 0 to 4294967295" Text3 is a simple data type whose format is Number. It is the problem of data type that VB does not support.? Plz guide me what may be the problem????? Thanks in adv...
-
Code is- If Text3.Text > 42949672945 Then MsgBox "Should be between 0 to 4294967295" When I save it, a # is added to the 42949672945 and code becomes like this- If Text3.Text > 42949672945# Then MsgBox "Should be between 0 to 4294967295" Text3 is a simple data type whose format is Number. It is the problem of data type that VB does not support.? Plz guide me what may be the problem????? Thanks in adv...
jainiraj wrote:
42949672945
you should avoid those magic constants. If they are the result of some calculation, just write the calculation; and if there is a symbol for them, use the symbol. Here you seem to want (1<<32)-1 which is UInt32.MaxValue Furthermore, 42949672945 isn't an acceptable value, as numeric constants by default are signed integers, so they can't exceed (1<<31)-1 which is Int32.MaxValue Finally, you need to convert your Text3 content to a number; there are .NET methods for that purpose. And since you are accepting the entire range of unsigned integer, it can all boil down to:
Dim val as UInt32;
Dim OK as boolean=UInt32.TryParse(Text3.Text, val)
if Not OK Then MsgBox(...):)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
jainiraj wrote:
42949672945
you should avoid those magic constants. If they are the result of some calculation, just write the calculation; and if there is a symbol for them, use the symbol. Here you seem to want (1<<32)-1 which is UInt32.MaxValue Furthermore, 42949672945 isn't an acceptable value, as numeric constants by default are signed integers, so they can't exceed (1<<31)-1 which is Int32.MaxValue Finally, you need to convert your Text3 content to a number; there are .NET methods for that purpose. And since you are accepting the entire range of unsigned integer, it can all boil down to:
Dim val as UInt32;
Dim OK as boolean=UInt32.TryParse(Text3.Text, val)
if Not OK Then MsgBox(...):)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Thanks for ur reply.. But it is not working and give an error "No user defined UInt32" data type exist. Can u help me how to find max length of UInt32??
System.UInt32.MaxValue
which is 4,294,967,295. The problem with using UInt32 is that it's not CLS-compliant, so you might get some warnings about that.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
System.UInt32.MaxValue
which is 4,294,967,295. The problem with using UInt32 is that it's not CLS-compliant, so you might get some warnings about that.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Actually problem may be that I am using VB 6.0 and there is no UInt32 data type. Is it correct??
yes. if you are enquiring about VB6 you should put "VB6" in your message and subject line. Always. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Actually problem may be that I am using VB 6.0 and there is no UInt32 data type. Is it correct??
Yep. VB6 has no unsigned integer data types and doesn't have an integer type that supports a number that large. So, it's appending the "#" character to the number to force it to be treated as a Double, which is a floating point type. I highly suggest abandoning any new developement in VB6 and move to VB.NET.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak