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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.