Ok this question is more like 'what is the term used for such as event?'.
What I am trying to do with open a application config form in login window which is activated by combonation of keys pressed. for example alt+c or ctrl+alt+x.
I tried using every term i can think of to search for a solution but no luck so can someone please tell me what term i need to used to find solution for such.

Recommended Answers

All 14 Replies

You can use toolstripmenu control.

Where you can add shortcut for each item.

See if this helps.

Public Class Form1

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.Alt AndAlso e.KeyCode = Keys.C Then MsgBox("tada")
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.KeyPreview = True '// keep focus of Keys on Form.
    End Sub
End Class

The lines of code that you provided works well in debug mode. But when I build the package and install it on another computer, program crash after splash screen and before the login form is loaded. What am I doing wrong?

Seems that the issue is not the code I provided, it is a issue within your app..
Post your frmLogin code for evaluation.

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        If txtUserID.Text = Nothing Then
            If txtUserID.Text = Nothing Then
                UsernameLabel.ForeColor = Color.Red
                MsgBox("PLEASE ENTER USER ID")
            End If
        Else
            UsernameLabel.ForeColor = Color.Blue
            PasswordLabel.ForeColor = Color.Blue

            If funcAuthenticate(txtUserID.Text, txtPassword.Text) = True Then
                My.Settings.CurrentUser = txtUserID.Text
                My.Settings.UserAccess = funcGetAccessCode(txtUserID.Text)
                frmMain.Show()
                frmMain.IsMdiContainer = True
                frmMain.stxtUserID.Caption = txtUserID.Text
                frmMain.stxtUserName.Caption = funcGetName(txtUserID.Text)
                Me.Close()
            Else
                MsgBox("Invalid User Id and Password")
            End If
        End If




    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub frmLogin_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.KeyPreview = True

        If My.Settings.FirstTime = True Then
            frmInitialConfig.Show()
        End If

        If My.Settings.SaveUser = True Then
            cbRemember.Checked = True
            txtUserID.Text = My.Settings.UserID
        End If
    End Sub

    Protected Function funcAuthenticate(ByVal UserID As String, ByVal pass As String)
        Dim SqlConnection As New SqlConnection(My.Settings.SqlConnectionString)
        Dim cmd As New SqlCommand
        Dim result As Object
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "SELECT Password FROM tblUser WHERE UserID = '" & UserID & "'"
        cmd.Connection = SqlConnection

        Try
            SqlConnection.Open()
            result = cmd.ExecuteScalar
            SqlConnection.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
            Return False
        End Try

        If result = pass Then
            Return True
        Else
            Return False
        End If

    End Function

    Protected Function funcGetAccessCode(ByVal UserID As String)
        Dim SqlConnection As New SqlConnection(My.Settings.SqlConnectionString)
        Dim cmd As New SqlCommand
        Dim result As String
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "SELECT AccessCode FROM tblUser WHERE UserID = '" & UserID & "'"
        cmd.Connection = SqlConnection

        Try
            SqlConnection.Open()
            result = cmd.ExecuteScalar
            SqlConnection.Close()
            Return result
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Return Nothing
    End Function

    Protected Function funcGetName(ByVal UserID As String)
        Dim SqlConnection As New SqlConnection(My.Settings.SqlConnectionString)
        Dim cmd1 As New SqlCommand
        Dim cmd2 As New SqlCommand
        Dim result1 As String
        Dim result2 As String
        cmd1.CommandType = CommandType.Text
        cmd1.CommandText = "SELECT FirstName FROM tblUser WHERE UserID = '" & UserID & "'"
        cmd1.Connection = SqlConnection

        cmd2.CommandType = CommandType.Text
        cmd2.CommandText = "SELECT LastName FROM tblUser WHERE UserID = '" & UserID & "'"
        cmd2.Connection = SqlConnection

        Try
            SqlConnection.Open()
            result1 = cmd1.ExecuteScalar
            result2 = cmd2.ExecuteScalar
            SqlConnection.Close()
            Return String.Format("{0} {1}", result1, result2)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Return Nothing
    End Function

    Private Sub frmLogin_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.Alt AndAlso e.KeyCode = Keys.Z Then frmInitialConfig.Show()
    End Sub
frmMain.stxtUserID.Caption = txtUserID.Text
                frmMain.stxtUserName.Caption = funcGetName(txtUserID.Text)

Is it a vb6.0 code?

If not where you get caption property???

commented: + rep. for providing possible solutions to threads on this forum. :) +10

its a vb.net code.
it might have been from a addons that I have. I believe stxtUserID is textbox or textlabel in status bar but I am not so sure. I have all of my codes with me but Im not in front of computer with Visual Studio so if you pm me the line number, i'll look it up.

Line 17/18, uses .Caption, which I believe is vb6 for .Text. Change those to .Text and let us know the result on the foreign p.c. when trying to run the app..

Thanks Code
Will try when I return to my office.

My buddy in the office told me that .caption is part of DevExpress status bar textlabel and it uses caption instead of text. but I will try to replace it with regular textbox from visual studio once i get back in the office.

.Caption from DevExpress? Kind of lame from my point of view, if it is just a .Text Property.

lol just found out there are multiple pages to posts....
well yeah my buddy just tried to run the app on the test terminal and it still doesnt work with the caption part of the code gone.
I think we are going to rebuild this form and try to see if the problem continues...

Remove all the db(database) code from the Form and test. If it runs without issues, close this thread and start a new one regarding your "new" issue. Thanks in advance and glad I could provide assistance thus far.:)

Arite, my boss got it figured out and it was a missing assembly or .dll
Well thanks for your help code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.