what i wanted is to connect class1 to class 2, in class1 i declared 6 controls, 2 lbls, 2 txtboxes and 2 btns, it is a login application in vb.net 2003,
now i have another class 2, which i have declared a lbl , btn, panel and two lnklbls.
i know the ".show" concept but it didnt work with classes, here's my code pls.. hellp to this one i browsed books but it doesnt say much even MOC, thanks in advace....
Expand|Select|Wrap|Line Numbers
- Public Class log 'class1
- Inherits Form1
- Public txtbox1 As TextBox
- Public txtbox2 As TextBox
- Public WithEvents btn1 As Button
- Public WithEvents btn2 As Button
- Public lbl1 As Label
- Public lbl2 As Label
- Dim b As New Form2
- Public Sub log()
- Me.txtbox1 = New TextBox
- Me.txtbox2 = New TextBox
- Me.btn1 = New Button
- Me.btn2 = New Button
- Me.lbl1 = New Label
- Me.lbl2 = New Label
- Me.txtbox1.Left = 120
- Me.txtbox1.Top = 70
- Me.Controls.Add(txtbox1)
- Me.txtbox2.Left = 120
- Me.txtbox2.Top = 110
- Me.Controls.Add(txtbox2)
- Me.btn1.Text = "Login"
- Me.btn1.Top = 170
- Me.btn1.Left = 40
- Me.Controls.Add(btn1)
- Me.btn2.Text = "Cancel"
- Me.btn2.Top = 170
- Me.btn2.Left = 140
- Me.Controls.Add(btn2)
- Me.lbl1.Text = "Username"
- Me.lbl1.Top = 70
- Me.lbl1.Left = 40
- Me.Controls.Add(lbl1)
- Me.lbl2.Text = "Password"
- Me.lbl2.Top = 110
- Me.lbl2.Left = 40
- Me.Controls.Add(lbl2)
- End Sub
- Public Sub New()
- MyBase.New()
- log()
- End Sub
- Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
- If txtbox1.Text = "1" And txtbox2.Text = "P@ssw0rd" Then
- MsgBox("hello User 1")
- Else
- b.Show() ' i wanted here to declare b as class2 and see its controls or objects
- End If
- End Sub
- Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
- Application.Exit()
- End Sub
- End Class
- Public Class frm2 'class 2, it isnt completed at this time,
- Inherits Form2
- Public lbl1 As Label
- Public WithEvents btn1 As Button
- Public WithEvents lnklbl1 As LinkLabel
- Public Sub frm2()
- Me.lbl1 = New Label
- Me.btn1 = New Button
- Me.lnklbl1 = New LinkLabel
- Me.lbl1.Text = "Invalid Username and Password!"
- Me.lbl1.Top = 70
- Me.lbl1.Left = 70
- Me.lbl1.Height = 40
- Me.Controls.Add(lbl1)
- End Sub
- Public Sub New()
- MyBase.New()
- frm2()
- End Sub
- End Class