如何在vb.net中创建一个只有按钮和没有文本框的登录表单 [英] how do I create a login form in vb.net with only buttons nd no text boxes

查看:113
本文介绍了如何在vb.net中创建一个只有按钮和没有文本框的登录表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表单由按钮4rm 1 - 9组成。用户输入密码,输入最后一位数字时,应显示一条合适的信息。

The form consist of buttons 4rm 1 - 9. User enters their password and when the final digit is entered a suitable message should be displayed.

推荐答案

试用以下示例:

Try out the following example:
Public Class DigitalLock

    Dim pin As String = ""
    Dim secret As String = "21"
    Dim count As Int16 = 1

    Private Sub DigitalLock_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        pin = pin & "1"
        If count = 2 Then
            GrantEntry()
        Else
            count = count + 1
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        pin = pin & "2"
        If count = 2 Then
            GrantEntry()
        Else
            count = count + 1
        End If
    End Sub


    Private Sub GrantEntry()
        If pin = secret Then
            MessageBox.Show("Passed")
        Else
            MessageBox.Show("Failed")
        End If
    End Sub

End Class



这个简单的程序模拟了一个双按钮数字锁。正确的引脚是21。阅读代码并理解逻辑。根据您的需要进行调整。

在每次尝试之后,您都必须重新启动程序,因此您应该在每次尝试后添加自己的代码以重置它。那是你的功课。


This simple program simulates a 2-button digital lock. The correct pin is "21". Read the code and understand the logic. Adapt this to your need.
At it is, after every attempt, you have to restart the program, so you should add your own code to reset it after every attempt. That is your homework.


这篇关于如何在vb.net中创建一个只有按钮和没有文本框的登录表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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