Results 1 to 2 of 2

Thread: Answer without a button

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Glasgow, MT, USA
    Posts
    44
    Im making a program and want to answer a question like old QBasic input. with Text. How do I do that with VB5?

  2. #2
    Guest
    Well I don't know if this is what you want but you
    could put a text box on the Form and make it respond
    to a KeyPress event.

    For example: If the question is "How old are you?"
    you put something like this, but first, add a module
    and place the following line of code in it:

    Public YourAge As Integer

    Now add this to a TextBox's Keypress event.

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    
    ' If the enter key is pressed then...
    If KeyAscii = 13 Then 
       'If the question in the label is How old are you...
       If lblQuestion.Caption = "How old are you?" Then
          YourAge = Text1.Text 'Save the variable
          'Change lblQuestion to a new question 
          lblQuestion = "Your Phone Number?" 
       End If
    End If
    End Sub
    What this does is when the enter key is pressed, the
    program checks if the qustion is "How old are you" then if
    it is, number in the textbox is stored into the variable YourAge.
    Then the lblQuestion is set to a new Question!

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