Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello there, i want a code that checks a key if it is pressed, the code will be:

if If num_of_routing = 1 And "_refresh button is pressed" then messagebox.show("Make sure you have made the first route"


i need the code or function of the _refresh button if pressed , am very new to VB, so thanks for every one.
Posted

What you need to do is put your code into the Click event handler for the refresh button - that way, you have eliminated part of your test, so you end up with:
VB
If Num_Of_Routing = 1 Then
  MessageBox.Show("Make sure you have made the first route")
End If
To get the Click event handler, open up your form in Visual Studio, and double click on the button. This will either create an empty Click event handler for you, or take you to one that you've added previously.
 
Share this answer
 
Please, read this:
Scope in VB[^]
Variable and Method scope in VB[^]

1) Start new "Windows application" project
2) Place on the form 2 buttons and set properties for them:
button A - Name: RefreshBtn
button B - Name: OtherBtn
3) Copy code below and paste it into your Form1 module class
VB
Public Class Form1
    Dim iKeyPressed As Integer = 0

    Private Sub RefreshBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshBtn.Click
        iKeyPressed += 1
    End Sub

    Private Sub OtherBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OtherBtn.Click
        MsgBox("Refresh button was pressed: " & iKeyPressed.ToString & " times", MsgBoxStyle.Information, "Info...")
    End Sub
End Class
 
Share this answer
 
If you want to capture a key press, then you should take a look at ProcessCmdKey.

Search for that in the Internet (or msdn) and you will get plenty of details and instructions on how to use it.

Anyway, I've never (from vb6) used vb and a simple google search has made it...

Hope this helps... :rose:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900