触发器代码.docx
- 文档编号:14717093
- 上传时间:2023-06-26
- 格式:DOCX
- 页数:19
- 大小:163.39KB
触发器代码.docx
《触发器代码.docx》由会员分享,可在线阅读,更多相关《触发器代码.docx(19页珍藏版)》请在冰点文库上搜索。
触发器代码
Dima,b,c,d,f(0To9),g(0To9),j(0To9),k(0To9),l(0To9),m(0To9),i,N,e,r,s,tAsInteger'定义变量和数组
PrivateSubCommand1_Click()
IfIsNumeric(Text1.Text)=FalseThen'如输入不为数字
MsgBox"输入有误"'弹出对话框
Text1.Text="":
Text1.SetFocus:
ExitSub'清空Text光标在Text闪烁,并退出Sub
EndIf
a=Val(Text1.Text)
Label2.Caption="":
Label3.Caption=""'清空Label
Label5.Caption="":
Label4.Caption="Qn1"
SelectCase(a)'SelectCase语句选择
Case"1"
Text3.Enabled=True'Text变为不能输入
Text5.Enabled=False
Text2.MaxLength=1:
Text3.MaxLength=1'Text最大输入长度为1
Label2.Caption="S":
Label3.Caption="R"
Case"2"
Text3.Enabled=True:
Text5.Enabled=False
Text2.MaxLength=1:
Text3.MaxLength=1
Label2.Caption="J":
Label3.Caption="K"
Case"3"
Text3.Enabled=False:
Text5.Enabled=False
Text2.MaxLength=1:
Label2.Caption="D"
Case"4"
Text3.Enabled=False:
Text5.Enabled=False
Text2.MaxLength=1:
Label2.Caption="T"
Case"11"
Text3.Enabled=True:
Text5.Enabled=False
Text2.MaxLength=10:
Text3.MaxLength=10
Label2.Caption="S序列":
Label3.Caption="R序列"
Case"22"
Text3.Enabled=True:
Text5.Enabled=False
Text2.MaxLength=10:
Text3.MaxLength=10
Label2.Caption="J序列":
Label3.Caption="K序列"
Case"33"
Text3.Enabled=False:
Text5.Enabled=False
Text2.MaxLength=10:
Label2.Caption="D序列"
Case"44"
Text3.Enabled=False:
Text5.Enabled=False
Text2.MaxLength=10:
Label2.Caption="T序列"
Case"12"
Text3.Enabled=True:
Text5.Enabled=True
Label2.Caption="S序列":
Label3.Caption="R序列":
Label5.Caption="Qn2"
Case"13"
Text3.Enabled=True:
Text5.Enabled=True
Label2.Caption="S序列":
Label3.Caption="R序列":
Label5.Caption="Qn2"
Case"14"
Text3.Enabled=True:
Text5.Enabled=True
Label2.Caption="S序列":
Label3.Caption="R序列":
Label5.Caption="Qn2"
Case"23"
Text3.Enabled=True:
Text5.Enabled=True
Label2.Caption="J序列":
Label3.Caption="K序列":
Label5.Caption="Qn2"
Case"24"
Text3.Enabled=True:
Text5.Enabled=True
Label2.Caption="J序列":
Label3.Caption="K序列":
Label5.Caption="Qn2"
Case"34"
Text3.Enabled=False:
Text5.Enabled=True
Label2.Caption="D序列":
Label5.Caption="Qn2"
CaseElse
Label4.Caption=""
MsgBox"输入有误":
ExitSub:
EndSelect:
EndSub
PrivateSubCommand2_Click()
Form1.Cls'清空Form
IfIsNumeric(Text1.Text)=FalseThen
MsgBox"输入有误":
Text1.Text="":
Text1.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text2.Text)=FalseThen
MsgBox"输入有误":
Text2.Text="":
Text2.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text4.Text)=FalseThen
MsgBox"输入有误":
Text4.Text="":
Text4.SetFocus:
ExitSub
EndIf
a=Val(Text1.Text):
b=Val(Text2.Text)
c=Val(Text3.Text):
d=Val(Text4.Text):
r=Val(Text5.Text)
SelectCase(a)
Case"1"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
Ifb=1Andc=1Then
MsgBox"不允许":
ExitSub
Else
Ifb=0Andc=0Then
e=d
Else
Ifb=0Andc=1Then
e=0
Else
Ifb=1Andc=0Then
e=1
EndIf:
EndIf:
EndIf:
EndIf
t=e:
Printe
Case"2"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
Ifb=0Andc=0Then
e=d
Else
Ifb=0Andc=1Then
e=0
Else
Ifb=1Andc=0Then
e=1
Else
Ifb=1Andc=1Andd=0Then
e=1
Else
Ifb=1Andc=1Andd=1Then
e=0
EndIf:
EndIf:
EndIf:
EndIf:
EndIf:
Printe
Case"3"
e=b:
Printe
Case"4"
Ifb=0Then
e=d
Else
Ifb=1Andd=0Then
e=1
Else
Ifb=1Andd=1Then
e=0
EndIf:
EndIf:
EndIf:
Printe
Case"11"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)'取Text里内容的长度
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
e=d
Else
Iff(i)=0Andg(i)=1Then
e=0
Else
Iff(i)=1Andg(i)=0Then
e=1
Else
Iff(i)=1Andg(i)=1Then
MsgBox"不允许":
ExitSub
EndIf:
EndIf:
EndIf:
EndIf:
Printe
d=e:
b=b-f(i)*(10^i):
c=c-g(i)*(10^i)
Nexti
Case"22"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
ExitSub:
Text3.Text="":
Text3.SetFocus
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
e=d
Else
Iff(i)=0Andg(i)=1Then
e=0
Else
Iff(i)=1Andg(i)=0Then
e=1
Else
Iff(i)=1Andg(i)=1Andd=0Then
e=1
Else
Iff(i)=1Andg(i)=1Andd=1Then
e=0
EndIf:
EndIf:
EndIf:
EndIf:
EndIf:
Printe
d=e:
b=b-f(i)*(10^i):
c=c-g(i)*(10^i)
Nexti
Case"33"
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
e=f(i)
Printe
b=b-f(i)*(10^i)
Nexti
Case"44"
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Iff(i)=0Then
e=d
Else
Iff(i)=1Andd=0Then
e=1
Else
Iff(i)=1Andd=1Then
e=0
EndIf:
EndIf:
EndIf:
Printe
d=e:
b=b-f(i)*(10^i)
Nexti
Case"12"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text5.Text)=FalseThen
MsgBox"输入有误":
Text5.Text="":
Text5.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
j(i)=d
Else
Iff(i)=0Andg(i)=1Then
j(i)=0
Else
Iff(i)=1Andg(i)=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Then
MsgBox"不允许"
EndIf:
EndIf:
EndIf:
EndIf
b=b-f(i)*(10^i):
c=c-g(i)*(10^i):
k(i)=1-j(i)
Ifj(i)=0Then
e=0
Else
e=1
EndIf
Printe
d=e
Nexti
Case"13"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text5.Text)=FalseThen
MsgBox"输入有误":
Text5.Text="":
Text5.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
j(i)=d
Else
Iff(i)=0Andg(i)=1Then
j(i)=0
Else
Iff(i)=1Andg(i)=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Then
MsgBox"不允许":
ExitSub
EndIf:
EndIf:
EndIf:
EndIf
b=b-f(i)*(10^i):
c=c-g(i)*(10^i):
e=j(i)
Printe
d=e
Nexti
Case"14"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text5.Text)=FalseThen
MsgBox"输入有误":
Text5.Text="":
Text5.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
j(i)=d
Else
Iff(i)=0Andg(i)=1Then
j(i)=0
Else
Iff(i)=1Andg(i)=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Then
MsgBox"不允许":
ExitSub
EndIf:
EndIf:
EndIf:
EndIf
b=b-f(i)*(10^i):
c=c-g(i)*(10^i):
d=j(i)
Ifj(i)=0Then
e=r
Else
Ifj(i)=1Andr=0Then
e=1
Else
Ifj(i)=1Andr=1Then
e=0
EndIf:
EndIf:
EndIf:
Printe
r=e
Nexti
Case"23"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text5.Text)=FalseThen
MsgBox"输入有误":
Text5.Text="":
Text5.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
j(i)=d
Else
Iff(i)=0Andg(i)=1Then
j(i)=0
Else
Iff(i)=1Andg(i)=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Andd=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Andd=1Then
j(i)=0
EndIf:
EndIf:
EndIf:
EndIf:
EndIf
b=b-f(i)*(10^i):
c=c-g(i)*(10^i):
e=j(i)
Printe
d=e
Nexti
Case"24"
IfIsNumeric(Text3.Text)=FalseThen
MsgBox"输入有误":
Text3.Text="":
Text3.SetFocus:
ExitSub
EndIf
IfIsNumeric(Text5.Text)=FalseThen
MsgBox"输入有误":
Text5.Text="":
Text5.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Ifc>=10^iThen
g(i)=1
Else
g(i)=0
EndIf
Iff(i)=0Andg(i)=0Then
j(i)=d
Else
Iff(i)=0Andg(i)=1Then
j(i)=0
Else
Iff(i)=1Andg(i)=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Andd=0Then
j(i)=1
Else
Iff(i)=1Andg(i)=1Andd=1Then
j(i)=0
EndIf:
EndIf:
EndIf:
EndIf:
EndIf
d=j(i):
b=b-f(i)*(10^i):
c=c-g(i)*(10^i)
Ifj(i)=0Then
e=r
Else
Ifj(i)=1Andr=0Then
e=1
Else
Ifj(i)=1Andr=1Then
e=0
EndIf:
EndIf:
EndIf:
Printe
r=e
Nexti
Case"34"
IfIsNumeric(Text5.Text)=FalseThen
MsgBox"输入有误":
Text5.Text="":
Text5.SetFocus:
ExitSub
EndIf
N=Len(Text2.Text)
Fori=N-1To0Step-1
Ifb>=10^iThen
f(i)=1
Else
f(i)=0
EndIf
Iff(i)=0Then
e=r
Else
Iff(i)=1Andr=0Then
e=1
Else
Iff(i)=1Andr=1Then
e=0
EndIf:
EndIf:
EndIf
b=b-f(i)*(10^i)
Printe
r=e
Nexti:
EndSelect:
EndSub
PrivateSubText1_Click()
Text1.Text="":
EndSub
PrivateSubText1_KeyPress(KeyAsciiAsInteger)
IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0'只能输入数字
EndSub
PrivateSubText2_click()
Text2.Text="":
EndSub
PrivateSubText2_KeyPress(KeyAsciiAsInteger)
IfKeyAscii<48OrKeyAscii>49ThenKeyAscii=0'只能输入0或1
EndSub
Private
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 触发器 代码