vbscript代码编造程序求助~!谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/31 06:37:33
书上看到一段代码!!!如下:
<html>
<head>
<title>过程小示例</title>
<script language="VBScript">
Function Checknumber (string)
Dim str1, i, element
str1=trim (string)
for i=1 to len (str1)
element=mid (str1 , i, 1)
if (asc (str1) < asc ("0") ) or (asc (str1) > asc("9") ) then
Checknumber=false
Exit function
end if
next
Checknumber=true
End Function
</script>
</head>
<body>
<h1 align="center"><font size="7">过程小示例</font></h1>
<hr>
<form name="frm1">
<p>please input number:<input type="text" name="T1" size="20"></p>
<p> <input type="submit" value="提交" name="B1"></p>
</form>
<script language="vbscript">
sub

书上的没加控件,这回试试!

Public Class Form1
Dim i As Integer = 0
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ErrorProvider1.SetError(TextBox1, "")
ErrorProvider1.SetError(TextBox2, "")
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "必须输入用户名!")
TextBox1.Focus()
Exit Sub
End If
If TextBox2.Text = "" Then
ErrorProvider1.SetError(TextBox2, "必须输入密码!")
TextBox2.Focus()
Exit Sub
End If

If TextBox1.Text = "cheng" And TextBox2.Text = "123456" Then
Label3.Text = "输入正确!"
Label3.Visible = True
Label3.ForeColor = Color.Blue
Else
i = i + 1