Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to pass values from one form to another in Visual Basic.Net

Author: DevASP
Download Source Code : 520_Sendmessage.zip

In this article i will try to explain you how you can send values from one form to another in Visual Basic.Net.

Create new application using vb.net and drag six labels, five combo boxes and a button

 

Double click on the form and write the following code on from load event

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

comboBox1.Text = "A"

comboBox2.Text = "A"

comboBox3.Text = "A"

comboBox4.Text = "A"

comboBox5.Text = "A"

End Sub

 

Double click on the button and write the following code on button click event

 

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

Dim dlgfrom2 As New Form2

dlgfrom2.writeMessage(comboBox1.Text, comboBox2.Text,                                comboBox3.Text, comboBox4.Text, comboBox5.Text)

If DialogResult.Yes = dlgfrom2.ShowDialog() Then

                  MsgBox("Result is Ok", MsgBoxStyle.Information, "Result")

Else

MsgBox("Result is has some Problem", MsgBoxStyle.Critical, "Result")

End If

End Sub

 

Now include another from in your application and drag two labels and two buttons on it

 

Double click on the from2 and write the following code on from2 load event

 

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Button1.DialogResult = System.Windows.Forms.DialogResult.Yes

End Sub

 

Double click on the NO button and write the following code on the button click event

 

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

    Me.Close()

End Sub

 

Now include the following procedure in from2 which is called from form1

 

Public Sub writeMessage(ByVal ITC As String, ByVal OS As String, ByVal CLD As String, ByVal MA As String, ByVal JA As String)

        If (ITC = "A") Then

 

            Label2.Text = "Result of Intro to C is Excellent "

 

        ElseIf (ITC = "B") Then

 

            Label2.Text = "Result of Intro to C is Good "

 

        ElseIf (ITC = "C") Then

 

            Label2.Text = "Result of Intro to C is Average "

 

        ElseIf (ITC = "D") Then

 

            Label2.Text = "Result of Intro to C is Okay "

 

        ElseIf (ITC = "F") Then

 

            Label2.Text = "Result of Intro to C is Poor "

 

        End If

        ''''''''''''''''''''''

        If (OS = "A") Then

 

            Label3.Text += "Result of OS  is Excellent "

 

        ElseIf (OS = "B") Then

 

            Label3.Text += "Result of OS  is Good "

 

        ElseIf (OS = "C") Then

 

            Label3.Text += "Result of OS is Average "

 

        ElseIf (OS = "D") Then

 

            Label3.Text += "Result of OS is Okay "

 

        ElseIf (OS = "F") Then

 

            Label3.Text += "Result of OS is Poor "

 

        End If

        ''''''''''''''''''''''

        If (CLD = "A") Then

 

            Label4.Text += "Result of CLD  is Excellent "

 

        ElseIf (CLD = "B") Then

 

            Label4.Text += "Result of CLD  is Good "

 

        ElseIf (CLD = "C") Then

 

            Label4.Text += "Result of CLD is Average "

 

        ElseIf (CLD = "D") Then

 

            Label4.Text += "Result of CLD is Okay "

 

        ElseIf (CLD = "F") Then

 

            Label4.Text += "Result of CLD is Poor "

 

        End If

        ''''''''''''''''''''''

        If (MA = "A") Then

 

            Label5.Text += "Result of Math  is Excellent "

 

        ElseIf (MA = "B") Then

 

            Label5.Text += "Result of Math  is Good "

 

        ElseIf (MA = "C") Then

 

            Label5.Text += "Result of Math is Average "

 

        ElseIf (MA = "D") Then

 

            Label5.Text += "Result of Math is Okay "

 

        ElseIf (MA = "F") Then

 

            Label5.Text += "Result of Math is Poor "

 

        End If

        ''''''''''''''''''''''

        If (JA = "A") Then

 

            Label6.Text += "Result of Java  is Excellent "

 

        ElseIf (JA = "B") Then

 

            Label6.Text += "Result of Java  is Good "

 

        ElseIf (JA = "C") Then

 

            Label6.Text += "Result of Java is Average "

 

        ElseIf (JA = "D") Then

 

            Label6.Text += "Result of Java is Okay "

 

        ElseIf (JA = "F") Then

 

            Label6.Text += "Result of Java is Poor "

        End If

        ''''''''''''''''''''''

 

    End Sub

 

 

 

 

 

Article Comments
please send me mail about this article

Posted on 12/29/2006 4:26:07 AM by RBala

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Conversion of weight units using VB.Net

Disclaimer - Privacy
© 2002-2017 DevASP.net