stupid question i guess

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maharajakecil
    New Member
    • Mar 2008
    • 12

    stupid question i guess

    i had develop a GUI using vb6.0 and it source code but i really dont know whether my souce code is working or not. could somebody help me on this to check my souce code? one more thing, if i key in an integer in val(test) in the source code, the integer will be send to mscomm1 in hex format, right? thanks..
    [CODE=vb]
    Private Sub Form_Load()
    Form1.Caption = "App1"
    With MSComm1
    MSComm1.Handsha king = 2
    MSComm1.RThresh old = 2
    MSComm1.RTSEnab le = True
    MSComm1.Setting s = "9600,n,8,1 "
    MSComm1.SThresh old = 1
    MSComm1.PortOpe n = True
    MSComm1.InputLe n = 2
    MSComm1.DTREnab le = True

    End With
    Command1.Captio n = "&Send"
    Text1.Text = Val(test)
    End Sub

    Private Sub Command1_Click( )
    MSComm1.Output = Text1.Text
    End Sub[/CODE]
    Last edited by debasisdas; Mar 24 '08, 06:08 AM. Reason: added code=vb tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to check the code using Break points.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      1.establish the break point using F9 in the line of code u want to debug.
      2.run the code
      3.Use F8 to check the execution of the code line by line.

      Comment

      • maharajakecil
        New Member
        • Mar 2008
        • 12

        #4
        ok. i already done that. there is no error. can i ask question. if i want only the integer to be put in my text box, what is the instruction should i include? if i put integer, the output at mscomm1 is in hex? thanks. you are helping me a lots. i tried to finish my final year project

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          To Make TextBox to accept only numeric write this code in Textbox's KeyPress Event:

          [code=vb]
          If KeyAscii <> 8 Then 'Allow BackSpace
          If InStr("01234567 89", Chr(KeyAscii)) = 0 Then KeyAscii = 0
          End If
          [/code]

          Regards
          Veena

          Comment

          • maharajakecil
            New Member
            • Mar 2008
            • 12

            #6
            thanks veena but that not solve my problem yet. please check your PM. i had leave a message for you.please read...

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by maharajakecil
              ok. i already done that. there is no error. can i ask question. if i want only the integer to be put in my text box, what is the instruction should i include? if i put integer, the output at mscomm1 is in hex? thanks. you are helping me a lots. i tried to finish my final year project
              Are you talking about restricting what the user can type in there, or what?

              Assuming test is a string containing a numeric value, the code shown should place the number in the textbox.

              Although I'm not really familiar with the MSComm control, I'll be somewhat surprised if a number that you send to it is transmitted as a hex string. I would expect it to send out exactly what you give it.

              Comment

              • maharajakecil
                New Member
                • Mar 2008
                • 12

                #8
                that right. i'm try to restrict user to enter the numberic only. what shoul be adjusted to my source code? i'm really not sure about the about of mscomm. that why i'm aking the genius! i need number to send in hex string so that it can trigger my PIC circuit. thanks

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Filtering user input to accept only numbers has been covered a few times here recently - try the search box. Personally, I feel the MS Masked Edit control is probably your best bet, as it allows simple control over user input. I haven't used it in years, though.

                  If you have a number and want to convert it to a hex string, jsut use the Hex$() function.

                  Comment

                  Working...