vb操作题.docx
《vb操作题.docx》由会员分享,可在线阅读,更多相关《vb操作题.docx(15页珍藏版)》请在冰豆网上搜索。
vb操作题
代码:
PrivateSubCommand1_Click()
IfOption1.Value=TrueThen
Label1="我的母语是汉语"
EndIf
IfOption2.Value=TrueThen
Label1="我的母语是英语"
EndIf
IfOption3.Value=TrueThen
Label1="我的母语是日语"
EndIf
EndSub
代码:
PrivateSubCommand1_Click()
Form1.Print"show"
EndSub
PrivateSubForm_Click()
Form1.Cls
EndSub
代码:
PrivateSubCommand1_Click()
IfCheck1.Value=0Then
IfCheck2.Value=0Then
Text1.Text="我选的课程是"
Else
Text1.Text="我选的课程是高等数学"
EndIf
EndIf
IfCheck1.Value=1Then
IfCheck2.Value=0Then
Text1.Text="我选的课程是物理"
Else
Text1.Text="我选的课程是物理和高等数学"
EndIf
EndIf
EndSub
代码:
DimarrN(10)AsInteger注意这句是在通用那里的
(温馨提示:
红色是需要我们自己填补的)
PrivateSubCommand1_Click()
Dimmax,iAsInteger
max=arrN
(1)
Fori=2To10
IfarrN(i)>maxThen
max=arrN(i)
EndIf
Nexti
Print
Print"最大值:
";max
EndSub
PrivateSubCommand2_Click()
Dimmin,iAsInteger
min=arrN
(1)
Fori=2To10
IfarrN(i)min=arrN(i)
EndIf
Nexti
Print
Print"最小值:
";min
EndSub
PrivateSubForm_Activate()
Randomize
Fori=1To10
arrN(i)=Int(Rnd*1000)+0
PrintarrN(i);
Nexti
EndSub
代码:
PrivateSubCommand1_Click()
DimaAsInteger
a=Val(Text1.Text)*Val(Text2.Text)
Picture1.Printa
EndSub
代码:
PrivateSubForm_Click()
IfCheck1.Value=1AndCheck2.Value=1AndOption1.Value=TrueThen
Label1="选修音乐和体育"
Else
IfCheck1.Value=1AndCheck2.Value=1AndOption2.Value=TrueThen
Label1="不选修音乐和体育"
Else
IfCheck2.Value=1AndOption1.Value=TrueThen
Label1="只选修音乐"
Else
IfCheck2.Value=1AndOption2.Value=TrueThen
Label1="不选修音乐"
Else
IfCheck1.Value=1AndOption1.Value=TrueThen
Label1="只选修体育"
Else
IfCheck1.Value=1AndOption2.Value=TrueThen
Label1="不选修体育"
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndSub
调节隐藏将按钮的属性那
改为false
代码:
PrivateSubCommand1_Click()
Print"计算机等级考试"
EndSub
PrivateSubForm_Click()
Command1.Visible=True
EndSub
代码:
PrivateSubList1_Click()
i=MsgBox("是否删除",vbYesNo)
SelectCasei
Case6
List1.RemoveItemIndex
EndSelect
EndSub
本来是这样的
填完后是这样的
代码:
PrivateSubCommand1_Click()
DimfileinAsString
DimfileoutAsString
DimnumberAsInteger
DimcpAsInteger
DimlpAsInteger
DimothersAsInteger
DimtringAsString
number=0
cp=0
lp=0
others=0
filein=App.Path&"\inzhyy22.txt"
fileout=App.Path&"\outzhyy22.txt"
OpenfileinForInputAs#1
OpenfileoutForOutputAs#2
Input#1,tring
strlench=Len(tring)
Fori=1Tostrlench
ch=Mid(tring,i,1)
IfAsc(ch)>=48AndAsc(ch)<=57Then
number=number+1
ElseIfAsc(ch)>=65AndAsc(ch)<=90Then
cp=cp+1
ElseIfAsc(ch)>=97AndAsc(ch)<=122Then
lp=lp+1
Else
others=others+1
EndIf
Nexti
Text1.Text=cp
Text2.Text=lp
Text3.Text=number
Text4.Text=others
Print#2,"大写字符个数:
";cp&"小写字符个数:
";lp&"数字:
";number&"其他字符:
";others
Close#2
Command1.Caption="完成"
Command1.Enabled=False
EndSub
PrivateSubCommand2_Click()
End
EndSub