我想检查一个if语句 [英] i want to check an if statement

查看:103
本文介绍了我想检查一个if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想要一个检查按键是否被按下的代码,该代码将是:

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"



我需要_refresh按钮的代码或功能(如果按下),对于VB来说是个新手,所以谢谢大家.



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

推荐答案

您需要做的是将您的代码输入刷新按钮的Click事件处理程序中-这样,您就消除了部分测试,因此最终得到:
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:
If Num_Of_Routing = 1 Then
  MessageBox.Show("Make sure you have made the first route")
End If

要获取Click事件处理程序,请在Visual Studio中打开表单,然后双击按钮.这将为您创建一个空的Click事件处理程序,或将您带到您之前添加的事件处理程序.

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.


请阅读以下内容:
VB中的范围 [ VB中的变量和方法范围 [ 2)放置在窗体2按钮上并为其设置属性:
按钮A-名称:RefreshBtn
按钮B-名称:OtherBtn
3)复制下面的代码并将其粘贴到您的Form1模块类中
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
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


如果要捕获按键,然后您应该看一下ProcessCmdKey.

在Internet(或msdn)中搜索该内容,您将获得大量有关使用它的详细信息和说明.

无论如何,我从未(从vb6起)使用过vb,而简单的Google搜索已使之成为...

希望对您有所帮助...:rose:
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:


这篇关于我想检查一个if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆