用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
在窗体中建立一个文本框text1,multiline属性为true,scrollBars属性为2-vertical
复制进如下代码:
Private
Sub
Form_Load()
Dim
a&,
b$
For
a
=
100
To
200
If
a
Mod
3
=
0
Then
b
=
b
&
Str(a)
Next
a
Text1Text
=
b
End
Sub
---------我是华丽丽的分割线--------
dim
a(1
to
10)
as
long
dim
Temp()
as
long
‘保存能被3整除的数
dim
s
as
string
dim
n
as
integer
for
i=1
to
10
a(i)=inputbox("Please
input
data!")
next
i
for
i=1
to
10
if
(a(i)
mod
2)
then
n=n+1
s=s
&
cstr(a(i))
&
","
end
if
redim
temp(n)
as
long
dim
v
v=split(s,",")
for
i=0
to
ubound(v)
temp(i)=v(i)
next
i
题目一:
Private Sub Text1_Change()
Text2Text = Text1Text
End Sub
题目二:
Private Sub Command1_Click()
Text1Text = "程序设计第一步:设计界面"
End Sub
Private Sub Command2_Click()
Text1Text = "程序设计第二步:属性设置"
End Sub
Private Sub Command3_Click()
Text1Text = "程序设计第三步:编写代码"
End Sub
题目三:
Private Sub Command1_Click()
Text1PasswordChar = ""
End Sub
题目四:
运行结果:
23
23
23
hellonihao
hellonihao
hello 100
helloI
100nihao
Inihao
先写这么多 - - 先睡觉去了。。。明儿再说!
以上就是关于用vb编写程序全部的内容,包括:用vb编写程序、用VB编写程序、VB简易程序设计代码等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)