Variables in MsgBox ? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Variables in MsgBox ?

iasghostiasghost Posts: 4Member
I am fooling around with a program at school, and I want to have th use enter some information in, click a button and have a message box come up with the varible data AND hardcoded words. for example a message box that says:
(text1.text "has" txtammount.text "with" txtoustanding.text "checks in the bank.")
is this possible, or am I just a dreamer?
One time, in programming class, I stuck an external CD burner up my USP port....

Comments

  • GazzaladGazzalad Posts: 85Member
    No dreaming.. Quite easy..

    Say you have a form (Form1) with a command button (CmdBut1) and a text box (TxtBox1). In the text box you want them to type in their name and display it in a message box.. The code in the button click procedure could be:

    Private Sub CmdBut1_Click()

    MsgBox "Hello" & TxtBox1.Text, vbOKOnly

    End Sub

    Ie all you need to do is seperate the 'text parts' with a &.
    so could also read
    MsgBox "Hello" & TxtBox1.text & "How are you", vbOkOnly

    Another point is by using the vbCrLf option (Visual basic character return line feed). This will put anything after on a new line. eg:

    MsgBox "Hello" & TxtBox1.Text & vbCrLf & "How Are You", vbOKOnly

    In your example:

    (text1.text & "has" & txtammount.text & "with" & txtoustanding.text & "checks in the bank.")


    Hope this helps...

    G

    : I am fooling around with a program at school, and I want to have th use enter some information in, click a button and have a message box come up with the varible data AND hardcoded words. for example a message box that says:
    : (text1.text "has" txtammount.text "with" txtoustanding.text "checks in the bank.")
    : is this possible, or am I just a dreamer?
    : One time, in programming class, I stuck an external CD burner up my USP port....
    :

  • iasghostiasghost Posts: 4Member
    Ahhh! thanks, O completly forgot about boolean!
    : No dreaming.. Quite easy..
    :
    : Say you have a form (Form1) with a command button (CmdBut1) and a text box (TxtBox1). In the text box you want them to type in their name and display it in a message box.. The code in the button click procedure could be:
    :
    : Private Sub CmdBut1_Click()
    :
    : MsgBox "Hello" & TxtBox1.Text, vbOKOnly
    :
    : End Sub
    :
    : Ie all you need to do is seperate the 'text parts' with a &.
    : so could also read
    : MsgBox "Hello" & TxtBox1.text & "How are you", vbOkOnly
    :
    : Another point is by using the vbCrLf option (Visual basic character return line feed). This will put anything after on a new line. eg:
    :
    : MsgBox "Hello" & TxtBox1.Text & vbCrLf & "How Are You", vbOKOnly
    :
    : In your example:
    :
    : (text1.text & "has" & txtammount.text & "with" & txtoustanding.text & "checks in the bank.")
    :
    :
    : Hope this helps...
    :
    : G
    :
    : : I am fooling around with a program at school, and I want to have th use enter some information in, click a button and have a message box come up with the varible data AND hardcoded words. for example a message box that says:
    : : (text1.text "has" txtammount.text "with" txtoustanding.text "checks in the bank.")
    : : is this possible, or am I just a dreamer?
    : : One time, in programming class, I stuck an external CD burner up my USP port....
    : :
    :
    :

    One time, in programming class, I stuck an external CD burner up my USP port....

Sign In or Register to comment.