+ Reply to Thread
Results 1 to 5 of 5

multiline Input Box

  1. #1
    Registered User
    Join Date
    09-22-2006
    Posts
    39

    multiline Input Box

    Hi

    I have written te following code:

    Private Sub Workbook_Open()
    Dim stTools As Variant
    Dim ireply As Integer

    Do
    Do
    stTools = Application.InputBox( _
    Prompt:="Please type the tool numbers you are using for this job:" _
    Title:="Tool List", Type:=1)
    Loop While stTools = ""
    'If the user has canceled the operation.
    If stTools = False Then Exit Sub

    ireply = MsgBox(Prompt:="You have entered the folllowing tools: " & stTools & " Is this correct?", _
    Buttons:=vbYesNoCancel, Title:="Tools Inputted")

    If ireply = vbNo Then ireply = False

    If ireply = vbYes Then Exit Sub

    If ireply = vbCancel Then Exit Sub
    Loop While ireply = False

    Exit Sub


    Firstly, I'm very new to all this and I am assuming this is very messy and would appreciate any tips on how to tidy it up.

    However, my question!

    I would like the inputBox to have 3 lines which the user will type upto 3 different integers (tool serial numbers), rather than typing the three numbers onto one line.

    How can I do this? I want to be able to call the 3 integers later to put in an email (if this is important?).


    Thanks in advance.

    Chris

  2. #2
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    have you tried userforms before? what you can have is create your own customised input box. then you can place them in separate fields which you can have transfered onto a worksheet which you could then email all with the touch of a button

  3. #3
    Forum Contributor
    Join Date
    12-12-2005
    Posts
    667
    I changed your code to:
    Sub parts()
    Dim stTools As String
    Dim ireply As String
    Do
    stTools = Application.InputBox(Prompt:="Please type the tool numbers you are using for this job:", Title:="Tool List", Type:=1)
    Loop While stTools = ""

    'If the user has canceled the operation.
    If stTools = False Then Exit Sub
    Do
    ireply = MsgBox(Prompt:="You have entered the folllowing tools: " & stTools & " Is this correct?", _
    Buttons:=vbYesNoCancel, Title:="Tools Inputted")
    If ireply = vbNo Then
    ireply = False
    parts
    ElseIf ireply = vbYes Then
    Exit Sub
    ElseIf ireply = vbCancel Then
    Exit Sub
    End If
    Loop While ireply = False
    End Sub

    I would strongly suggest that you use VBE to insert a module with this code:
    Sub Main()
    UserForm1.Show
    End Sub

    and a UserForm with at least 3 Textboxes and 2 buttons; you would add this code:
    Public iReply1, iReply2, iReply3 As String
    Private Sub CommandButton1_Click()
    iReply1 = TextBox1.Text
    iReply2 = TextBox2.Text
    iReply3 = TextBox3.Text
    Me.Hide
    'TextBox1.Text = ""
    'TextBox2.Text = ""
    'TextBox3.Text = ""
    End Sub
    Private Sub CommandButton2_Click()
    Me.Hide
    TextBox1.Text = ""
    TextBox2.Text = ""
    TextBox3.Text = ""
    End Sub




    UserForm
    Best regards,

    Ray

  4. #4
    Registered User
    Join Date
    09-22-2006
    Posts
    39
    Thanks very much guys.

    I have never heard of userforms in excel before and I will now go away and try to work them out.

    Also, thanks Ray for the code lesson, greatly appreciated!

    Thanks again....

  5. #5
    Registered User
    Join Date
    11-19-2006
    Posts
    15

    Multiline InputBox

    For multiline inputbox use &Chr(13)& between the lines
    Example: stTools = Application.InputBox(Prompt:="Please type the tool" &Chr(13)& "numbers you are using for this job:", Title:="Tool List", Type:=1)

    This will show two lines

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1