Consulting

Results 1 to 3 of 3

Thread: Want VBA Textbox information to show VBA MsgBox

  1. #1
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    2
    Location

    Want VBA Textbox information to show VBA MsgBox

    Hi,

    I am wondering if it is possible to have a VBA msgbox to show information from a Textbox that's in a VBA Userform. The text I have below works upto the point of where I what it to call "Are you sure you want to Confirm this Quantity" (The last step). What I want it to do is to read the textbox 3 value and display it in the message box. Is this possible or do I just give up on this or is there a code that will enable this to work.


    Private Sub CommandButton2_Click()
    
        If Me.TextBox2.Value = "" Then
           MsgBox "Please add a product into product box"
           Exit Sub
        End If
    
    
        If IsNumeric(Me.TextBox3.Value) = False Then
           MsgBox "Invalid Qty"
           Exit Sub
        End If
        
        Dim Answer As VbMsgBoxResult
    
    
        Answer = MsgBox("Are you sure you want to Submit this Entry", vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Submission")
                                    
    If Answer = vbYes Then
        
        Answer = MsgBox("Are you sure you want to Confirm this Quantity" & vbLf & _
                 IsNumeric(Me.TextBox3.Value).Text, vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Quantity")
                Exit Sub
                End If
        
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Stock In-Out")
    
    
    Dim lr As Long
    lr = Application.WorksheetFunction.CountA(sh.Range("A:A"))
    
    
    sh.Range("A" & lr + 1).Value = Me.TextBox2.Value
    
    
    
    
    If Me.OptionButton1.Value = True Then
        sh.Range("B" & lr + 1).Value = "IN"
    Else
        sh.Range("B" & lr + 1).Value = "OUT"
    End If
    
    
    sh.Range("C" & lr + 1).Value = Me.TextBox4.Value
    sh.Range("D" & lr + 1).Value = Me.TextBox3.Value
    sh.Range("E" & lr + 1).Value = Me.TextBox6.Value
    
    
    MsgBox "Updated!!!"
    
    
    
    
    
    
    End Sub
    Thanks

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Just guessing here

    Post a small sample workbook to be a better answer

        Dim Answer As VbMsgBoxResult
        Answer = MsgBox("Are you sure you want to Submit this Entry", vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Submission")
                                    
        If Answer = vbYes Then
            Answer = MsgBox("Are you sure you want to Confirm this Quantity" & vbLf & _
                    Format(Me.TextBox3.Text, "#,##0"), vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Quantity")
            If Answer = vbNo Then Exit Sub
        End If
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    2
    Location
    Thanks Paul_Hossler, that has work marvellously.

    Thanks for your help

    Thanks
    Donald

Posting Permissions

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