Visual Basic Development Bookmark and Share   
 Home > Visual Basic General > Multiple textboxes in messagebox
 

Multiple textboxes in messagebox

Ok I need to have a message box pop up when a user clicks the "Add Patient" button and the message box should have multiple textboxes which include Patient name, Patient ID, etc. I guess my question is can I do this with a message box or do I need a new form to pop up when the button is clicked. The form is connected to a database and the info entered should be added to the "Patients" data table.
vishvishal2000  Tuesday, December 01, 2009 4:45 AM
You cant do this process with Message box, it has its own limitations, u can use a Window form to implement this

hope this helps...



Narayanan Dayalan - Zeetaa Business Solutions ------- Please "Mark As Answer", if my answer works well with ur Query
Narayanan Dayalan  Tuesday, December 01, 2009 4:54 AM
Message Box is only consist of label or information. You need to add new form to have multiple textboxes
Harrie KalaChakra  Tuesday, December 01, 2009 5:01 AM
You can include multiple items of information in a single message box by building a multi-line string. Eg:
Dim msgString As String = "Name: " & PatientName & vbCrLf _
   & "Patient Id: " & PatientId & vbCrLf _
   & "Doctor: " & DoctorName
MsgBox(msgString)
But you cannot use a message box to enter data. Are you thinking of an input box?
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.interaction.inputbox(VS.80).aspx
http://msdn.microsoft.com/en-us/library/6z0ak68w(VS.80).aspx

The input box can only accept one item of information at a time. If you need to input multiple items, you will need a form. The form could be created as a dialog. See Project / Add Windows Form... / Dialog.
Acamar  Tuesday, December 01, 2009 5:07 AM
What you want is simply called a modal form.

Create it yourself using a form and show it using

dim frm as new myCreatedForm
frm.ShowDialog
dim the firstTextBoxValue = frm.ThePublicPropertyWhereIHavePlacedTheValueIN
.
.
.
frm.Dispose
Success
Cor
Cor Ligthert  Tuesday, December 01, 2009 5:35 AM
I had a similiar problem like this earlier.

Add another'Windows Form' to your project, we'll say this is "form2". Now add a textbox to that form.

Go back to form1 and add this string to the button click event.

Replace textbox# and combobox# with your own values, refer to the name(s) of the boxes to decide which value holds what content.

this code is from an e-business card I'm working on, but should do just fine for you.

Private

Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

With Form2.TextBox1

.Text =

"Customer Information" & vbNewLine & vbNewLine

.Text &=

"Contact No: "

.Text &= TextBox1.Text & vbNewLine

.Text &=

"Client Name: "

.Text &= TextBox2.Text & vbNewLine

.Text &=

"Business Name: "

.Text &= TextBox3.Text & vbNewLine

.Text &=

"Business Type: "

.Text &= ComboBox1.Text & vbNewLine

.Text &=

"Product No.: "

.Text &= TextBox4.Text & vbNewLine

.Text &=

"Product Color: "

.Text &= TextBox5.Text & vbNewLine

.Text &=

"Product Type: "

.Text &= ComboBox2.Text & vbNewLine

.Text &=

"Design Type: "

.Text &= ComboBox3.Text & vbNewLine

.Text &=

"Design Color: "

.Text &= ComboBox4.Text & vbNewLine

.Text &=

"Quantity: "

.Text &= ComboBox5.Text & vbNewLine

.Text &=

"Special Instructions: "

.Text &= TextBox6.Text & vbNewLine

End With

Form2.Show()

End Sub

  • Proposed As Answer byGothickfish Tuesday, December 01, 2009 6:27 AM
  •  
Gothickfish  Tuesday, December 01, 2009 6:23 AM
thank you all for the reply
I will work on this and update you guys very soon.
vishvishal2000  18 hours 45 minutes ago
I created a new form that will pop up when a user clicks the add button. Empty form pop-ups so that user can enter the new data. I played with the codes and it is working now.
Thank you
vishvishal2000  5 hours 27 minutes ago
Gothickfish please format code when you post it so it is easier to read .
coding for fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
Please format the code in your posts with the button . Makes it easier to read .
bdbodger  5 hours 22 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• VB2008: Help declaring an array of Objects
• Generating a globally unique ID of 16 char string
• code to clear data in a column
• Saving files when installing the app.
• AutoScrollPosition property setter didn't take the value
• How to allow the user to save their prefered settings in visual basic during runtime
• shell class problem
• FYI: Solution won't Build / Resolution
• is it possible to add calculated field in datagridview
• Saving word docs to sql server