Userform which presents Calculation answers in MsgBox

Charmwah

Board Regular
Joined
Jan 23, 2017
Messages
64
Hi all

Relative newb here, so might be a daft question. I have created a basic Userform which asks for 3 dimensions from a user, on clicking the OK button the idea is that a MsgBox delivers the required information which is derived from a few calculations. See my code so far below:

Code:
Private Sub OKButton_Click()
    Dim Msg As String
    Dim LineLoad As Integer
        LineLoad = 1100
    Dim LLLFFL As Integer
        LLLFFL = LineLoad - FFLTextBox.Value
    Msg = "Glazing details as follows: "
    Msg = Msg & vbNewLine
    Msg = Msg & vbNewLine
    Msg = Msg & WidthTextBox & "mm X " & HeightTextBox & "mm (width x height)"
    Msg = Msg & vbNewLine
    Msg = Msg & Pane1TextBox & "mm " & Pane1ListBox.Value & " glass LOADED pane"
    Msg = Msg & vbNewLine
    Msg = Msg & Pane2TextBox & "mm " & Pane2ListBox.Value & " glass OTHER pane"
    Msg = Msg & vbNewLine
    Msg = Msg & vbNewLine
[COLOR=#ff0000]    Msg = Msg & "LINE LOAD @ "[/COLOR]
[COLOR=#ff0000]        If HeightTextBox.Value + FFLTextBox.Value < LineLoad Then[/COLOR]
[COLOR=#ff0000]            MsgBox = Msg & "n/a"[/COLOR]
[COLOR=#ff0000]        ElseIf HeightTextBox.Value + FFLTextBox.Value >= LineLoad Then[/COLOR]
[COLOR=#ff0000]            LLLFFL[/COLOR]
[COLOR=#ff0000]        End If[/COLOR]
    Msg = Msg & vbNewLine
    Msg = Msg & "POINT LOAD @ " & WorksheetFunction.Sum(WidthTextBox.Value) / 2 & " X " & WorksheetFunction.Sum(HeightTextBox.Value) / 2
    Msg = Msg & vbNewLine
    MsgBox Msg
    Unload LoadingUserForm
End Sub

I can't make the highlighted area work. I'm not 100% sure the MsgBox function can do what i'm asking, though logically it should be able to so I think its just my poor understanding of the code!:confused:

Thanks in advance!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Perhaps you need a msgbox here!!!
The Variable "LLLFFL" Does not relate to anything !!!!
Code:
If HeightTextBox.Value + FFLTextBox.Value < LineLoad Then
            MsgBox = Msg & "n/a"
        ElseIf HeightTextBox.Value + FFLTextBox.Value >= LineLoad Then
[COLOR=#FF0000][/COLOR]           [COLOR=#FF0000] Msgbox  [/COLOR]LLLFFL
        End If
 
Upvote 0
Hi MickG

Thanks for your response, but it does relate to something, its defined at the very start of the code...

Private Sub OKButton_Click()
Dim Msg As String
Dim LineLoad As Integer
LineLoad = 1100
Dim LLLFFL As Integer
LLLFFL = LineLoad - FFLTextBox.Value
Perhaps you need a msgbox here!!!
The Variable "LLLFFL" Does not relate to anything !!!!
Code:
If HeightTextBox.Value + FFLTextBox.Value < LineLoad Then
            MsgBox = Msg & "n/a"
        ElseIf HeightTextBox.Value + FFLTextBox.Value >= LineLoad Then
           [COLOR=#FF0000] Msgbox  [/COLOR]LLLFFL
        End If
 
Upvote 0
It's ok, i've worked it out myself.

The simple method is to move the whole If statement out of the Msgbox code and enter the eventual answer as a its own variable (LLOAD). See below:

Code:
Dim LLOAD As String
        If HeightTextBox.Value + FFLTextBox.Value < LineLoad Then
            LLOAD = "n/a"
        ElseIf HeightTextBox.Value + FFLTextBox.Value >= LineLoad Then
            LLOAD = LLLFFL
        End If
 
Upvote 0

Forum statistics

Threads
1,216,361
Messages
6,130,180
Members
449,563
Latest member
Suz0718

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top