|
-
Nov 30th, 2004, 05:30 AM
#1
Thread Starter
Lively Member
passing variables to other windows
When I double click on a name a pop up window appears with this person's data (method show()) how can I pass a variable to that new window from the window I double clicked on?
Thanks in advance.
-
Nov 30th, 2004, 05:40 AM
#2
Hyperactive Member
like this?
VB Code:
Private Sub Label1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.DoubleClick
Dim f As New Form5()
f.Label1.Text = Me.Label1.Text
f.Show()
End Sub
-
Nov 30th, 2004, 05:47 AM
#3
Thread Starter
Lively Member
Well almost, the thing is that the variable isn't to be shown it is just an internarl ID number to retriever information from a database. So i want to pass it to do, in the popping form, something like "select * from customers where idcustomers=variable".
Hey thanks.
-
Nov 30th, 2004, 06:00 AM
#4
Hyperactive Member
this sample
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New Form5()
f.generateId(Me.TextBox1.Text)
f.Show()
End Sub
in Form5:
VB Code:
Dim cn As New SqlConnection("user id=sa; password=password; initial catalog=northwind")
Sub generateId(ByVal s As String)
Dim cmdText As String = "select* from student where Idno = '" & s & "'"
cn.Open()
Dim cm As New SqlCommand(cmdText, cn)
Dim dr As SqlDataReader = cm.ExecuteReader
While dr.Read
TextBox1.Text = dr.GetValue(1).ToString 'lastname
End While
dr.Close()
cn.Close()
End Sub
-
Nov 30th, 2004, 06:43 AM
#5
Thread Starter
Lively Member
alright that sure helps, thanks lots
-
Nov 30th, 2004, 06:44 AM
#6
Hyperactive Member
no probs
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|