求以下V B的 编写程序,即新建项目时选择Windows应用程序
解决时间 2021-08-21 04:49
- 提问者网友:原来太熟悉了会陌生
- 2021-08-20 20:37
应该就是那种要窗体运行的,
唔该边位高手帮下忙啦!运行可以先好发过来o ^_^
(1) 输入一批成绩(假设0≤成绩≤100,输入时以负数为结束标志,至少有一个成绩),求其中的最高分与最低分之差。
(2) 编写计算1+1/2+1/3+1/4+…..1/100的程序,把结果显示出来。
(3) 判断回文。如果一个字符串正反读字符顺序都相同,称之为回文,例如,level,madam。编制一个程序,输入任意一个字符串,判断它是否为回文字符串。
(4)计算1~100之间的偶数之和。
(5) 输入要购买的3种商品的单价和数量,输出所用的总金额。要求输入和输出均使用文本框。
最佳答案
- 五星知识达人网友:从此江山别
- 2021-08-20 21:22
第一题:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s = TextBox1.Text
s = Regex.Match(s, "(.*?)-.*").Groups(1).Value
s = Regex.Replace(s, "\s+", " ")
s = s.TrimEnd
Dim sa = s.Split(New Char() {" "})
Dim min, max As Double
max = CDbl(sa(0))
min = max
For i As Integer = 1 To sa.Length - 1
Dim t = CDbl(sa(i))
If min > t Then
min = t
ElseIf max < t Then
max = t
End If
Next
MsgBox("最高分:" & max & vbCrLf & "最低分:" & min & vbCrLf & "分差:" & max - min)
End Sub
第二题:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As Double = 0
For i = 1 To 100
s += 1 / i
Next
MsgBox("1+1/2+1/3+1/4+…..1/100=" & s)
End Sub
第三题:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s = TextBox1.Text.ToCharArray
Array.Reverse(s)
If CStr(s) = TextBox1.Text Then
MsgBox("是回文")
Else
MsgBox("不是回文")
End If
End Sub
第四题:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s = 0
For i = 2 To 100 Step 2
s += i
Next
MsgBox("2+4+6+..+98+100=" & s)
End Sub
第五题:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p1 = CInt(TextBox1.Text)
Dim p2 = CInt(TextBox2.Text)
Dim p3 = CInt(TextBox3.Text)
Dim n1 = CDbl(TextBox4.Text)
Dim n2 = CDbl(TextBox5.Text)
Dim n3 = CDbl(TextBox6.Text)
Dim all = p1 * n1 + p2 * n2 + p3 * n3
MsgBox("总价是:" & all)
End Sub
我要举报
大家都在看
推荐资讯