Public Class Form1
'设置输入框只能输入数字,ImeMode属性设置为Disable
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsDigit(e.KeyChar) Or e.KeyChar = Chr(8) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text <> "" Then
Select Case TextBox1.TextLength
Case 1
TextBox2.Text = TextBox1.Text & " is less than 10"
Case 2 To 3
TextBox2.Text = TextBox1.Text & " is " & 10 ^ (TextBox1.TextLength - 1) & " to " & (10 ^ TextBox1.TextLength) - 1
Case Else
TextBox2.Text = TextBox1.Text & " is greater than 1000"
End Select
Else
TextBox2.Text = ""
End If
End Sub
End Class
在visual studio里新建一个控制台应用程序
代码:
Module Module1
Sub Main()
Console.WriteLine("请输入:")
Dim num As Double = Abs(Val(Console.ReadLine))
Select Case num
Case Is < 10
Console.WriteLine(num & "is 0 to 10")
Console.Read()
Case Is < 100
Console.WriteLine(num & "is 10 to 100")
Console.Read()
Case Is < 1000
Console.WriteLine(num & "is 100 to 1000")
Console.Read()
Case Is >= 1000
Console.WriteLine(num & "is above 1000")
Console.Read()
End Select
End Sub
End Module