General discussion

  • Creator
    Topic
  • #2257626

    VB problem

    Locked

    by silvamsn ·

    select case texttotal.text
    case 40
    label1.caption=”sssxx”
    case 50
    label1.caption=”sddxx”
    case else
    label1.caption=”ssbhx”
    end select in this vb prog. in the first time i ictivate the code, it skip the first line (case 40 ). it means suppose texttotal.text was 40, prog. should type in label1 as “sssxx”. but at the first time I run the program it shows what is under case else statement. what is the error on this . Please help me.

All Comments

  • Author
    Replies
    • #3199546

      Reply To: VB problem

      by streamlogic ·

      In reply to VB problem

      Silvamsn,

      Since you are comparing text in a textbox, you will need to make sure the 40 and 50 are also strings. I would wrap them in quotes (“”) and make it case “40”, case “50”.

      Hope this helps,
      Curtis

      Curtis Hughes
      StreamLogic Inc.
      http://www.StreamLogicInc.com

    • #3199427

      Reply To: VB problem

      by cmiller5400 ·

      In reply to VB problem

      StreamLogic is correct. Wrap the 40 etc in quotes.

    • #3229987

      Reply To: VB problem

      by rmcnaught ·

      In reply to VB problem

      Try:

      select case texttotal.text
      case “40”
      label1.caption=”sssxx”
      case “50”
      label1.caption=”sddxx”
      case else
      label1.caption=”ssbhx”
      end select

    • #3231013

      Reply To: VB problem

      by clgan333 ·

      In reply to VB problem

      Try:

      Use val build in function to convert it into numeric number.

      Hope help…

      select case val(texttotal.text)
      case 40
      label1.caption=”sssxx”
      case 50
      label1.caption=”sddxx”
      case else
      label1.caption=”ssbhx”
      end select

    • #3283538

      Reply To: VB problem

      by truthcommission ·

      In reply to VB problem

      Both of the answers here are correct. However if, for some reason, you didn’t want to use the string value and wanted to use the integer value of the text. you could do a CINT to texttotal.text or maybe a CType(Texttotal.text,Integer), of course the data in texttotal would have to be an integer or you’ll get an invalid cast exception

Viewing 4 reply threads