求助用VB.NET 编写 程序是什么啊?
6.输入一个整数,将其数值按小于10、10~99、100~999、1000以上分类并显示。例如,输入358时,显示358is100to999。...
6. 输入一个整数,将其数值按小于10、10~99、100~999、1000以上分类并显示。例如,输入358时,显示358 is 100 to 999。
展开
2个回答
展开全部
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
代码:
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询