我该如何编码呢? [英] How do I code this ?

查看:71
本文介绍了我该如何编码呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个消息框[是/否消息框]询问用户是否要清除文本框,如果用户单击是否清除了文本框,如果没有则则保留文本框相同。这是使用的代码



我尝试过:



I want to add a message box [yes/no message box] that asks the user if he wants to clear the text boxes or not, if the user clicks yeas the text boxes are cleared and if no then the text boxes remain the same. This is the code used

What I have tried:

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        MsgBox("Do you want to clear all?", MsgBoxStyle.YesNo, "Clear the textboxes!")
        If MsgBoxResult.No Then
            TB1.Text = "0"
            TB2.Text = "0"
            TB3.Text = "0"
            TB4.Text = "0"
            TB5.Text = "0"
            L1.Text = "0"
            L2.Text = "0"
            L3.Text = "0"
            L4.Text = "0"
            L5.Text = "0"
            SCORE.Text = "0"
            Label10.Text = "Here"
        Else
            'what to put over here??
        End If
    End Sub

推荐答案

反转你的测试:

Reverse your test:
MsgBox("Do you want to clear all?", MsgBoxStyle.YesNo, "Clear the textboxes!")
If MsgBoxResult.Yes Then
    TB1.Text = "0"
    TB2.Text = "0"
    TB3.Text = "0"
    TB4.Text = "0"
    TB5.Text = "0"
    L1.Text = "0"
    L2.Text = "0"
    L3.Text = "0"
    L4.Text = "0"
    L5.Text = "0"
    SCORE.Text = "0"
    Label10.Text = "Here"
End If

但是请开始使用.NET类而不是过时的VB6类: MessageBox类(System.Windows.Forms) [ ^ ]

But please, start using .NET classes instead of outdated VB6 ones: MessageBox Class (System.Windows.Forms)[^]


这篇关于我该如何编码呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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