用VB实现上述功能的函数是:
Function fun(m, n) As Integer
Sum = 0
For i = 1 To 100
If i Mod m = 0 Or i Mod n = 0 Then
Sum = Sum + i
End If
Next i
fun = Sum
End Function
Private Sub Command1_Click()
m = CInt(InputBox("m="))
n = CInt(InputBox("n="))
Print "100以内能被"; m; "或"; n; "整除的数的总和="; fun(m, n)
End Sub
Private Sub Command1_Click()
Dim i%, n1%, n2%, sum%
If Op1Value = True Then
n1 = 100
n2 = 200
End If
If Op2Value = True Then
n1 = 200
n2 = 400
End If
sum = 0
For i = n1 To n2
If ss(i) Then sum = sum + i
Next
Text1 = sum
End Sub
Function ss(n As Integer) As Boolean
Dim i%
For i = 2 To n - 1
If n Mod i = 0 Then
ss = False
Exit Function
End If
Next
ss = True
End Function
Private Sub Command2_Click()
Open AppPath + "\outtxt" For Output As #1
Print #1, Text1Text
Close 1
End Sub
Private Sub Form_click()
Text1FontSize = 20
Text1FontBold = True
Text1Text = InputBox("")
Label1Caption = Text1Text
Label1ForeColor = vbRed
Label1FontName = "楷体_GB2312"
End Sub
如图所示
以上就是关于用vb编写程序全部的内容,包括:用vb编写程序、vb程序编写、求VB程序编写等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)