Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Classes in VB.net 1

Status
Not open for further replies.

CookieNZ

MIS
Apr 22, 2002
48
0
0
NZ
I am relatively new to VB.Net and to be honest modern programming in general (long gone are the days of Turbo Pascal) and I need some help with classes.

I want to pass a variable from one form, so that it can be used as part of connection string in a new form.

I have a button that I wish to launch a new form. I already know the field I want to pass, and have been trying :-

Private Sub btndetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndetail.Click

details(txtcustname.Text)

End Sub 'from the main form

And a new form:-

Private Sub Detail_Load(ByVal customer As String) Handles MyBase.Load

txtcustname.Text = customer


End Sub 'new form called details

Firstly, it does like 'details' and main form, nor does it like the 'Mybase.load'.

Any help?
 
Instantiate the form as an object first and call your own Sub.

Private Sub btndetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndetail.Click
dim frmDetails as new Details
details.MySub(txtcustname.Text)
End Sub

''''
Private Sub MyStart(ByVal customer As String)
txtcustname.Text = customer
Me.Show
End Sub Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Ta works fine, but I am struggling to read the relevant use the private detail_load procedure to automatically populate the relevant text boxes.

But

In the main form:-

Public Sub btndetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndetail.Click

Dim frmDetails As New Detail()
frmDetails.MySub(txtcustname.Text)

End Sub

In the details form:-

Public Sub MySub(ByVal customer As String)

cmdsupport = dbconn.CreateCommand

cmdsupport.CommandText = "select * from customers where cust = customer"

dbcustomers.SelectCommand = cmdsupport

dbcustomers.Fill(dscustomers, "Customers")

txtcustname.DataBindings.Add("Text", dscustomers.Tables("Customers"), "Customer")
txtusers.DataBindings.Add("Text", dscustomers.Tables("Customers"), "Users")

Me.Show()

End Sub

 
I think you've made a mistake in your SQL statement, it should look like this :

cmdsupport.CommandText = "select * from customers where cust = '" & customer & "'"

Don't forget all of the quotes!

Let me know if this helps,
Jan If this response was usefull to you, please mark it with a Star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top