473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

classes help.....

knychtell
hi, everyone, i just need some advice on how to create a connection between classes, it is very urgent....

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
  1. Public Class log        'class1
  2.     Inherits Form1
  3.  
  4.     Public txtbox1 As TextBox
  5.     Public txtbox2 As TextBox
  6.     Public WithEvents btn1 As Button
  7.     Public WithEvents btn2 As Button
  8.     Public lbl1 As Label
  9.     Public lbl2 As Label
  10.     Dim b As New Form2
  11.  
  12.     Public Sub log()
  13.         Me.txtbox1 = New TextBox
  14.         Me.txtbox2 = New TextBox
  15.         Me.btn1 = New Button
  16.         Me.btn2 = New Button
  17.         Me.lbl1 = New Label
  18.         Me.lbl2 = New Label
  19.  
  20.  
  21.         Me.txtbox1.Left = 120
  22.         Me.txtbox1.Top = 70
  23.         Me.Controls.Add(txtbox1)
  24.         Me.txtbox2.Left = 120
  25.         Me.txtbox2.Top = 110
  26.         Me.Controls.Add(txtbox2)
  27.  
  28.         Me.btn1.Text = "Login"
  29.         Me.btn1.Top = 170
  30.         Me.btn1.Left = 40
  31.         Me.Controls.Add(btn1)
  32.  
  33.  
  34.         Me.btn2.Text = "Cancel"
  35.         Me.btn2.Top = 170
  36.         Me.btn2.Left = 140
  37.         Me.Controls.Add(btn2)
  38.  
  39.         Me.lbl1.Text = "Username"
  40.         Me.lbl1.Top = 70
  41.         Me.lbl1.Left = 40
  42.         Me.Controls.Add(lbl1)
  43.  
  44.         Me.lbl2.Text = "Password"
  45.         Me.lbl2.Top = 110
  46.         Me.lbl2.Left = 40
  47.         Me.Controls.Add(lbl2)
  48.  
  49.  
  50.  
  51.  
  52.  
  53.     End Sub
  54.     Public Sub New()
  55.         MyBase.New()
  56.         log()
  57.  
  58.     End Sub
  59.  
  60.  
  61.  
  62.  
  63.     Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
  64.  
  65.         If txtbox1.Text = "1" And txtbox2.Text = "P@ssw0rd" Then
  66.             MsgBox("hello User 1")
  67.         Else
  68.             b.Show() ' i wanted here to declare b as class2 and see its controls or objects
  69.         End If
  70.     End Sub
  71.  
  72.     Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
  73.         Application.Exit()
  74.  
  75.     End Sub
  76. End Class
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. Public Class frm2    'class 2, it isnt completed at this time, 
  85.     Inherits Form2
  86.     Public lbl1 As Label
  87.     Public WithEvents btn1 As Button
  88.     Public WithEvents lnklbl1 As LinkLabel
  89.     Public Sub frm2()
  90.         Me.lbl1 = New Label
  91.         Me.btn1 = New Button
  92.         Me.lnklbl1 = New LinkLabel
  93.  
  94.  
  95.         Me.lbl1.Text = "Invalid Username and Password!"
  96.         Me.lbl1.Top = 70
  97.         Me.lbl1.Left = 70
  98.         Me.lbl1.Height = 40
  99.         Me.Controls.Add(lbl1)
  100.  
  101.  
  102.  
  103.  
  104.     End Sub
  105.     Public Sub New()
  106.         MyBase.New()
  107.         frm2()
  108.     End Sub
  109.  
  110. End Class
Feb 10 '07 #1
0 778

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
5
by: Wysiwyg | last post by:
I'm new to c# programming and can't figure out how to avoid duplicating common code in multiple classes when I'm restricted to using different system base classes.. I'm using c# in asp.net to write...
5
by: Anthony Evans | last post by:
Greetings I'm using VC++.NET to create a class library. The class library contains managed classes that wrap legacy unmanaged classes by the same name. I use regasm to register the DLL for...
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.