I'm retarded and can't find this on the net.

How do I pass data that i've stored in a variable via a textbox into a MessageBox?

MessageBox.Show("Name:", BName, MessageBoxButtons.OK, MessageBoxIcon.Information)

When I run this, BName does not show the name. BName is a name from a textBox BName.

Recommended Answers

All 8 Replies

Member Avatar for iamthwee
Dim var As String

var = txtBox.Text

MsgBox("Name: " & var)

I think.

Dim var As String

var = txtBox.Text

MsgBox("Name: " & var)

I think.

The & operator is used for string concatenation. And the & operator would work in the instance you show it in for C languages, not VB.NET:-|

Member Avatar for iamthwee

The & operator is used for string concatenation. And the & operator would work in the instance you show it in for C languages, not VB.NET:-|

No idea what you just said. That is, as far as I am aware legal vb.net syntax.

Try this if BName is a textbox.

MessageBox.Show("Name:", BName.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)

& works in vb net and vb6.

I found the syntax.

MessageBox.Show("Name: " & BName)

Sorry iamthwee, you were right.

I had a comma after "Name: " that was throwing me off!!!!!!

while trying to display msgbox using vb.net i got this error....

Inside insert button click,i wrote this

MsgBox("Inserted")

how to solve this error....

ERROR System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application

MessageBox.Show("Name:", BName.toString(), MessageBoxButtons.OK, MessageBoxIcon.Information)

thank you guys . i got it what i needed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.