Results 1 to 3 of 3

Thread: Passing the value,from a inptbx in a sbfunctn

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Location
    LONG iSLAND NY
    Posts
    8

    Question Passing the value,from a inptbx in a sbfunctn

    I have an inputbox that has to come up several times, I have decided to call out this Inputbox with a subfunction(due to being used 4 or more times).
    Here is the prob:
    The value of the inputbox is not being passed on.

    I have ran through the prgrm in step mode several time and can't quite figure out why!!
    Any sugeestions

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Code:
        strResponse = InputBox("Please enter a number")
    Now, you realize strResponse's life is only as long as the procedure is executing. If you need to persist it for the life of the project, either declare it as a form module varialble or public variable in a (.bas) module.

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Not really sure why you need to create a function to call the InputBox Function.

    Doing something like this
    Code:
    Private Sub Command1_Click()
        Text1.Text = getInputBox()
    End Sub
    
    Private Sub Command2_Click()
        Text2.Text = getInputBox()
    End Sub
    
    Private Function getInputBox()
        getInputBox = InputBox("Enter Data to place in text box", "Please Enter Data", "New Text")
    End Function
    Can be done with
    Code:
    Private Sub Command1_Click()
        Text1.Text = InputBox("Enter Data to place in text box", "Please Enter Data", "New Text")
    End Sub
    
    Private Sub Command2_Click()
        Text2.Text = InputBox("Enter Data to place in text box", "Please Enter Data", "New Text")
    End Sub
    Perhaps if you post your code, you could get additional help.

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