I want to pass variables from one form to an other.
I googled a lot but nothing seems to work for me.
I am a newbie so code example is importand to me
The variables i I need in the second form( called" Hulsview") are :" hulsbreedte" and" hulslengte".
To check if the varables are passed I added a textbox in the second form,called" hulsview" to check the variable" hulsbreedte".
The value selected in the combobox on on form1" hulsbreedte = HulsBreedte1.SelectedValue" returns always 0 in the textbox on de second form.
Here is te code form1:
And here the code for the second form:
I am using vb express 2010.
Thanks in advance,
Groover
I googled a lot but nothing seems to work for me.
I am a newbie so code example is importand to me
The variables i I need in the second form( called" Hulsview") are :" hulsbreedte" and" hulslengte".
To check if the varables are passed I added a textbox in the second form,called" hulsview" to check the variable" hulsbreedte".
The value selected in the combobox on on form1" hulsbreedte = HulsBreedte1.SelectedValue" returns always 0 in the textbox on de second form.
Here is te code form1:
VB.NET:
Imports System.Drawing.Drawing2D
Public Class Form1
Inherits System.Windows.Forms.Form
Public hlb As Point 'not used
Public hrb As Point 'not used
Public hlo As Point 'not used
Public hro As Point 'not used
Public hulsbreedte As Integer
Public hulslengte As Integer
Public OK As Integer 'not used
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Height = Screen.PrimaryScreen.Bounds.Height
Me.Width = Screen.PrimaryScreen.Bounds.Width / 2
End Sub
Private Sub ExitButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton2.Click
Application.Exit()
End Sub
Private Sub HulsBreedte1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HulsBreedte1.SelectedIndexChanged
hulsbreedte = HulsBreedte1.SelectedValue
End Sub
Private Sub HulsLengte1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HulsLengte1.SelectedIndexChanged
hulslengte = HulsLengte1.SelectedValue
HulsView.Show() 'second form
End Sub
End Class
And here the code for the second form:
VB.NET:
Imports System.Drawing.Drawing2D
Public Class HulsView
Inherits System.Windows.Forms.Form
Public hulsbreedte As Integer = Form1.hulsbreedte
Public hulslengte As Integer = Form1.hulslengte
Public ScrXY As Point
Public Centerpoint As Point
Private Sub HulsView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call ScreenResolution()
Me.Location = ScrXY
Me.Width = Screen.PrimaryScreen.Bounds.Width / 2
Me.Height = Screen.PrimaryScreen.Bounds.Height
End Sub
Public Function ScreenResolution()
Dim ScrX As Double = Screen.PrimaryScreen.Bounds.Width
ScrXY.X = ScrX / 2
ScrXY.Y = 0
Return ScrXY
End Function
Public Function FormCenter()
Dim FrmX As Double = Me.Location.X + Me.Bounds.Width
Dim FrmY As Double = Me.Location.Y + Me.Bounds.Height
Centerpoint.X = FrmX / 2
Centerpoint.Y = FrmY / 2
Return Centerpoint
End Function
Private Sub HulsView_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim Hulsoutline As New Drawing.Pen(Brushes.LightGray, 8)
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
Call FormCenter()
Dim point1 As New Point(point1.X, point1.Y)
point1.X = Centerpoint.X - hulsbreedte / 2
point1.Y = Centerpoint.Y - hulslengte / 2
Dim point2 As New Point(point2.X, point2.Y)
point2.X = Centerpoint.X + hulsbreedte / 2
point2.Y = Centerpoint.Y - hulslengte / 2
Dim point3 As New Point(point3.X, point3.Y)
point3.X = Centerpoint.X + hulsbreedte / 2
point3.Y = Centerpoint.Y + hulslengte / 2
Dim point4 As New Point(point4.X, point4.Y)
point4.X = Centerpoint.X - hulsbreedte / 2
point4.Y = Centerpoint.Y - hulslengte / 2
Dim curvePoints As Point() = {point1, point2, point3, point4}
7:
e.Graphics.DrawPolygon(Hulsoutline, curvePoints)
TextBox1.Text = Form1.hulsbreedte.ToString''
Me.Refresh()
End Sub
End Class
I am using vb express 2010.
Thanks in advance,
Groover