Hi guys. I'm using VB express 2005 and im having trouble calling one sub function from inside another. Can you help?
I have written an event procedure for a button click. Now i want to call that sub in the ENTER event of a textbox.
I have tried simply copying the name of the sub into the ENTER sub but it wont work, i get the error message "expression expected" and an underline under the "ByVal" part of the argument.
Imports MySql.Data.MySq lClient
Imports System.Data
Public Class frmLogin
Dim conn As MySqlConnection
Private Sub Button_cancel_C lick(ByVal sender As Object, ByVal e As System.EventArg s) Handles Button_cancel.C lick
Application.Exi t() 'kills the application/process
End Sub
Private Sub Button_login_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles Button_login.Cl ick
'an example connection string: server=localhos t; user id=mike; password=12345; database=in_out
conn = New MySqlConnection
Dim Ser, Use, Pas As String
Ser = TextBox_server. Text & ";"
Use = TextBox_usernam e.Text & ";"
Pas = TextBox_passwor d.Text & ";"
'
conn.Connection String = "server=" & Ser & "user id=" & Use & "password=" & Pas & "database=nfenl on_TestDB01"
'
Try
conn.Open()
MessageBox.Show ("Connection Opened Successfully")
conn.Close()
Catch myerror As MySqlException
MessageBox.Show ("Error Connecting to Database: " & myerror.Message )
Finally
conn.Dispose()
End Try
'
End Sub
Private Sub frmLogin_Load(B yVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
TextBox_server. Focus()
End Sub
Private Sub TextBox_passwor d_Enter(ByVal sender As Object, ByVal e As System.EventArg s) Handles TextBox_passwor d.Enter
Button_login_Cl ick(byval sender As Object, byval e As System.EventArg s) Handles Button_login.Cl ick
End Sub
End Class
I have written an event procedure for a button click. Now i want to call that sub in the ENTER event of a textbox.
I have tried simply copying the name of the sub into the ENTER sub but it wont work, i get the error message "expression expected" and an underline under the "ByVal" part of the argument.
Imports MySql.Data.MySq lClient
Imports System.Data
Public Class frmLogin
Dim conn As MySqlConnection
Private Sub Button_cancel_C lick(ByVal sender As Object, ByVal e As System.EventArg s) Handles Button_cancel.C lick
Application.Exi t() 'kills the application/process
End Sub
Private Sub Button_login_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles Button_login.Cl ick
'an example connection string: server=localhos t; user id=mike; password=12345; database=in_out
conn = New MySqlConnection
Dim Ser, Use, Pas As String
Ser = TextBox_server. Text & ";"
Use = TextBox_usernam e.Text & ";"
Pas = TextBox_passwor d.Text & ";"
'
conn.Connection String = "server=" & Ser & "user id=" & Use & "password=" & Pas & "database=nfenl on_TestDB01"
'
Try
conn.Open()
MessageBox.Show ("Connection Opened Successfully")
conn.Close()
Catch myerror As MySqlException
MessageBox.Show ("Error Connecting to Database: " & myerror.Message )
Finally
conn.Dispose()
End Try
'
End Sub
Private Sub frmLogin_Load(B yVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
TextBox_server. Focus()
End Sub
Private Sub TextBox_passwor d_Enter(ByVal sender As Object, ByVal e As System.EventArg s) Handles TextBox_passwor d.Enter
Button_login_Cl ick(byval sender As Object, byval e As System.EventArg s) Handles Button_login.Cl ick
End Sub
End Class
Comment