Results 1 to 10 of 10

Thread: string to int convertion

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2002
    Location
    Chennai
    Posts
    21

    Arrow string to int convertion

    Hi

    How to convert string to integer.

    For eg Myint = Text1.text dint work out.

    regards
    viswanathan

  2. #2
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    VB Code:
    1. intMyInt = Cint(txtText)

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    VB Code:
    1. MyInt = Cint(Text1.Text)

  4. #4
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    .Text is default for a Text box so you don't need to use it in code.

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Originally posted by GlenW
    .Text is default for a Text box so you don't need to use it in code.
    Valid point Glen, but I beleive its good practice - it makes
    you use the, or at least, makes you think about the .property
    you need to use.

  6. #6
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    Originally posted by Bruce Fox


    Valid point Glen, but I beleive its good practice - it makes
    you use the, or at least, makes you think about the .property
    you need to use.
    You're probably right Bruce, guess I'm just lazy.

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429



    (you and me both )

  8. #8
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    Guess our code didn't work or we'd have been thanked.

  9. #9
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    You might also want to use the Val function in order not to get a 13 Type Mismatch if the text box contains 'string' data instead of a number.
    VB Code:
    1. MyInt = Cint(Val(Text1.Text))
    Nate

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by Bruce Fox


    Valid point Glen, but I beleive its good practice - it makes
    you use the, or at least, makes you think about the .property
    you need to use.
    one other point on this... MS got rid of the default properties on controls in VB.NET because it was bad practice... just like they got rid of other bad bad things like variants and negative bounds in arrays.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width