Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Regarding long data type ..

Regarding long data type ..

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jainiraj
    wrote on last edited by
    #1

    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...

    D L 2 Replies Last reply
    0
    • J jainiraj

      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...

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #2

      Text3.text is a String data type, so you need to convert that string to a value to do a comparison with your 429....number.

      Dave Don't forget to rate messages!
      Find Me On: Web|Facebook|Twitter|LinkedIn

      1 Reply Last reply
      0
      • J jainiraj

        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...

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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.

        J 1 Reply Last reply
        0
        • L Luc Pattyn

          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.

          J Offline
          J Offline
          jainiraj
          wrote on last edited by
          #4

          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??

          D 1 Reply Last reply
          0
          • J jainiraj

            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??

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            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

            J 1 Reply Last reply
            0
            • D 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

              J Offline
              J Offline
              jainiraj
              wrote on last edited by
              #6

              Actually problem may be that I am using VB 6.0 and there is no UInt32 data type. Is it correct??

              L D 2 Replies Last reply
              0
              • J jainiraj

                Actually problem may be that I am using VB 6.0 and there is no UInt32 data type. Is it correct??

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • J jainiraj

                  Actually problem may be that I am using VB 6.0 and there is no UInt32 data type. Is it correct??

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups