主题:[讨论]跪求几个 VB的简单程序,,,在线等待~~~~~~~~~~~~~~~~
djhx1024
[专家分:0] 发布于 2009-11-30 17:56:00
1,编写一个 解决实际问题 的选择结构 程序
2、编写一个解决实际问题的 循环结构 程序
3、编写一二多模块的程序
4.编写一个 使用数组的程序
5、编写一个 用户界面的程序
回复列表 (共2个回复)
沙发
大懒猫 [专家分:220] 发布于 2009-12-02 08:41:00
选择结构
Private Sub Command1_Click()
If Text1.Text <> "" Then
score = Val(Text1.Text)
Select Case score
Case 0 To 59
Print "你的成绩不及格"
Case 60 To 69
Print "你的成绩是及格"
Case 70 To 79
Print "你的成绩是中等"
Case 80 To 89
Print "你的成绩是良好"
Case 90 To 100
Print "你的成绩是优秀"
Case Else
Print "你输入的成绩有问题!"
End Select
End If
End Sub
Private Sub Form_Load()
Text1.FontSize = 18
Text1.Text = ""
End Sub
循环结构且使用了数组:
Option Base 1
Private Sub Command1_Click()
Dim a(10) As Integer
Dim i, sum As Integer, average As Single
For i = 1 To 10
a(i) = InputBox("请输入:")
' Print a(i);
Next i
sum = 0
For i = 1 To 10
sum = sum + a(i)
Next i
average = sum / 10
Print "average="; average
End Sub
板凳
大懒猫 [专家分:220] 发布于 2009-12-02 08:45:00
'求S的N次方,3的600次方
'窗体文件内容
Private a() As Integer
Public w As Integer
Private Sub Command1_Click()
Dim n1, n, i, j, k, h, t, l, s As Integer
Picture1.Cls
s = Val(Text1.Text)
n = Val(Text2.Text)
Label1.Caption = Str(s) & "的" & n & "次方精确值"
n1 = Int(n * Log(s) / Log(10)) + 1
ReDim a(n1 + 1) As Integer
a(1) = 1
k = 1
w = 0
For i = 1 To n
For j = 1 To k
a(j) = a(j) * s
If a(j) > 9 Then w = 1
Next j
If w = 1 Then Call Module1.jwjs(k, w, a())
Next i
If n <> 0 Then
l = 1
For t = k To 1 Step -1
Picture1.FontSize = 12
Picture1.ForeColor = RGB(0, 0, 255)
Picture1.Print LTrim$(Right(Str(a(t)), 1));
If l Mod 40 = 0 Then Picture1.Print
l = l + 1
Next t
Picture1.Print
Picture1.Print
forcolor = RGB(255, 0, 0)
Picture1.Print Str(s) + "的" + LTrim(Str(n)) + "次方的位数是:"; LTrim(Str(k))
End If
End Sub
Private Sub Command2_Click()
End
End Sub
'标准模块内容:
Public q As Integer
Sub main()
q = 0
Form1.Show
End Sub
Public Sub jwjs(k, w, a() As Integer)
Dim n As Integer
For h = 1 To k
a(h + 1) = a(h + 1) + Int(a(h) / 10)
a(h) = a(h) - Int(a(h) / 10) * 10
If a(k + 1) > 0 Then k = k + 1
Next h
w = 0
End Sub
我来回复