VB源代码-键盘连击辅助
VB键盘字符代码
第0~32号及第127号(共34个)是控制字符或通讯专用字符,如控制符:LF(换行)、CR(回车)、FF(换页)、DEL(删除)、BEL(振铃)等;通讯专用字符:SOH(文头)、EOT(文尾)、ACK(确认)等;第33~126号(共94个)是字符,其中第48~57号为0~9十个阿拉伯数字;65~90号为26个大写英文字母,97~122号为26个小写英文字母,其余为一些标点符号、运算符号等。
注意:在计算机的存储单元中,一个ASCII码值占一个字节(8个二进制位),其最高位(b7)用作奇偶校验位。
所谓奇偶校验,是指在代码传送过程中用来检验是否出现错误的一种方法,一般分奇校验和偶校验两种。
奇校验规定:正确的代码一个字节中1的个数必须是奇数,若非奇数,则在最高位b7添1;偶校验规定:正确的代码一个字节中1的个数必须是偶数,若非偶数,则在最高位b7添1。
为了便于查询,以下列出ASCII码表:常用ASCII 码对照表第128~255号为扩展字符(不常用),如需要请下载:完整的8位ASCII 字符表keycode 是键盘上每一个按键对应的码keycode如下:keycode 0 =keycode 1 =keycode 2 =keycode 3 =keycode 4 =keycode 5 =keycode 6 =keycode 7 =keycode 8 = BackSpace BackSpace keycode 9 = Tab Tabkeycode 10 =keycode 11 =keycode 12 = Clearkeycode 13 = Enterkeycode 14 =keycode 15 =keycode 16 = Shift_Lkeycode 17 = Control_Lkeycode 18 = Alt_Lkeycode 19 = Pausekeycode 20 = Caps_Lockkeycode 21 =keycode 22 =keycode 23 =keycode 24 =keycode 25 =keycode 26 =keycode 27 = Escape Escapekeycode 28 =keycode 29 =keycode 30 =keycode 31 =keycode 32 = space spacekeycode 33 = Priorkeycode 34 = Nextkeycode 35 = Endkeycode 36 = Homekeycode 37 = Leftkeycode 38 = Upkeycode 39 = Rightkeycode 40 = Downkeycode 41 = Selectkeycode 43 = Executekeycode 44 =keycode 45 = Insertkeycode 46 = Deletekeycode 47 = Helpkeycode 48 = 0 equal braceright keycode 49 = 1 exclam onesuperior keycode 50 = 2 quotedbl twosuperior keycode 51 = 3 section threesuperior keycode 52 = 4 dollarkeycode 53 = 5 percentkeycode 54 = 6 ampersandkeycode 55 = 7 slash braceleft keycode 56 = 8 parenleft bracketleft keycode 57 = 9 parenright bracketright keycode 58 =keycode 59 =keycode 60 =keycode 61 =keycode 62 =keycode 63 =keycode 64 =keycode 65 = a Akeycode 66 = b Bkeycode 67 = c Ckeycode 68 = d Dkeycode 69 = e E EuroSignkeycode 70 = f Fkeycode 71 = g Gkeycode 72 = h Hkeycode 73 = i Ikeycode 74 = j Jkeycode 75 = k Kkeycode 76 = l Lkeycode 77 = m M mukeycode 78 = n Nkeycode 79 = o Okeycode 80 = p Pkeycode 81 = q Q atkeycode 82 = r Rkeycode 83 = s Skeycode 84 = t Tkeycode 85 = u Ukeycode 87 = w Wkeycode 88 = x Xkeycode 89 = y Ykeycode 90 = z Zkeycode 91 =keycode 92 =keycode 93 =keycode 94 =keycode 95 =keycode 96 = KP_0 KP_0keycode 97 = KP_1 KP_1keycode 98 = KP_2 KP_2keycode 99 = KP_3 KP_3keycode 100 = KP_4 KP_4keycode 101 = KP_5 KP_5keycode 102 = KP_6 KP_6keycode 103 = KP_7 KP_7keycode 104 = KP_8 KP_8keycode 105 = KP_9 KP_9keycode 106 = KP_Multiply KP_Multiply keycode 107 = KP_Add KP_Add keycode 108 = KP_Separator KP_Separator keycode 109 = KP_Subtract KP_Subtract keycode 110 = KP_Decimal KP_Decimal keycode 111 = KP_Divide KP_Divide keycode 112 = F1keycode 113 = F2keycode 114 = F3keycode 115 = F4keycode 116 = F5keycode 117 = F6keycode 118 = F7keycode 119 = F8keycode 120 = F9keycode 121 = F10keycode 122 = F11keycode 123 = F12keycode 124 = F13keycode 125 = F14keycode 126 = F15keycode 127 = F16keycode 128 = F17keycode 129 = F18keycode 131 = F20 keycode 132 = F21 keycode 133 = F22 keycode 134 = F23 keycode 135 = F24 keycode 136 = Num_Lock keycode 137 = Scroll_Lock keycode 138 =keycode 139 =keycode 140 =keycode 141 =keycode 142 =keycode 143 =keycode 144 =keycode 145 =keycode 146 =keycode 147 =keycode 148 =keycode 149 =keycode 150 =keycode 151 =keycode 152 =keycode 153 =keycode 154 =keycode 155 =keycode 156 =keycode 157 =keycode 158 =keycode 159 =keycode 160 =keycode 161 =keycode 162 =keycode 163 =keycode 164 =keycode 165 =keycode 166 =keycode 167 =keycode 168 =keycode 169 =keycode 170 =keycode 171 =keycode 172 =keycode 173 =keycode 174 =keycode 175 =keycode 176 =keycode 177 =keycode 178 =keycode 179 =keycode 180 =keycode 181 =keycode 182 =keycode 183 =keycode 184 =keycode 185 =keycode 186 =keycode 187 = acute gravekeycode 188 = comma semicolon keycode 189 = minus underscore keycode 190 = period colonkeycode 191 =keycode 192 = numbersign apostrophe keycode 193 =keycode 194 =keycode 195 =keycode 196 =keycode 197 =keycode 198 =keycode 199 =keycode 200 =keycode 201 =keycode 202 =keycode 203 =keycode 204 =keycode 205 =keycode 206 =keycode 207 =keycode 208 =keycode 209 =keycode 210 = plusminus hyphen macron keycode 211 =keycode 212 = copyright registered keycode 213 = guillemotleft guillemotright keycode 214 = masculine ordfeminine keycode 215 = ae AEkeycode 216 = cent yenkeycode 217 = questiondown exclamdownkeycode 218 = onequarter onehalf threequarters keycode 219 =keycode 220 = less greater barkeycode 221 = plus asterisk asciitildekeycode 222 =keycode 223 =keycode 224 =keycode 225 =keycode 226 =keycode 227 = multiply divisionkeycode 228 = acircumflex Acircumflex keycode 229 = ecircumflex Ecircumflex keycode 230 = icircumflex Icircumflex keycode 231 = ocircumflex Ocircumflex keycode 232 = ucircumflex Ucircumflex keycode 233 = ntilde Ntildekeycode 234 = yacute Yacutekeycode 235 = oslash Oobliquekeycode 236 = aring Aringkeycode 237 = ccedilla Ccedillakeycode 238 = thorn THORNkeycode 239 = eth ETHkeycode 240 = diaeresis cedilla currency keycode 241 = agrave Agrave atilde Atilde keycode 242 = egrave Egravekeycode 243 = igrave Igravekeycode 244 = ograve Ograve otilde Otilde keycode 245 = ugrave Ugravekeycode 246 = adiaeresis Adiaeresiskeycode 247 = ediaeresis Ediaeresiskeycode 248 = idiaeresis Idiaeresiskeycode 249 = odiaeresis Odiaeresiskeycode 250 = udiaeresis Udiaeresiskeycode 251 = ssharp question backslash keycode 252 = asciicircum degreekeycode 253 = 3 sterlingkeycode 254 = Mode_switch。
vb简单地计算机源代码
vb简单的计算机源代码.txt如果青春的时光在闲散中度过,那么回忆岁月将是一场凄凉的悲剧。
杂草多的地方庄稼少,空话多的地方智慧少。
即使路上没有花朵,我仍可以欣赏荒芜。
Private Sub Command1_Click()Form1.Caption = "欢迎使用智能计算器" '载入默认正常显示If Check1.Value = "0" Then '1类分歧ElseIf Text1.T ext = "" Or Text2.T ext = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"Else '2类分歧Dim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a + bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfIf Check1.Value = "1" Then '1类分歧ElseIf Text1.T ext = "" Or Text2.T ext = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then '2类分歧Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"Else '2类分歧Dim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d + eText3.T ext = fEnd IfEnd SubPrivate Sub Command2_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" ThenForm1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" ThenForm1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d - eText3.T ext = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a - bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfEnd SubPrivate Sub Command3_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d * eText3.T ext = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a * bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfEnd SubPrivate Sub Command4_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Val(Text2.T ext) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.T ext = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a / bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfIf Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Val(Text2.T ext) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.T ext = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d / eText3.T ext = fEnd IfEnd SubPrivate Sub Command5_Click()Form1.Caption = "欢迎使用智能计算器"Text1.T ext = ""Text2.T ext = ""Text3.T ext = ""End SubPrivate Sub Command6_Click()Form1.Caption = "欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub Command7_Click()EndEnd SubPrivate Sub Command8_Click()Form1.Caption = "欢迎使用智能计算器" If Text3.T ext <> "" ThenText1.T ext = T ext3.T extText2.T ext = ""Text3.T ext = ""ElseForm1.Caption = "xataliq kuruldi"Text3.T ext = "没有结果无法继续"End IfEnd SubPrivate Sub Text2_Change()End SubPrivate Sub 乘_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d * eText3.T ext = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a * bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfEnd SubPrivate Sub 除_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Val(Text2.T ext) = "0" ThenForm1.Caption = "xataliq kuruldi"Text3.T ext = "分数的分子不能为零"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a / bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfIf Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "错误"Text3.T ext = "运算数值不能为空"ElseIf Val(Text2.T ext) = "0" ThenForm1.Caption = "错误"Text3.T ext = "分数的分子不能为零"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d / eText3.T ext = fEnd IfEnd SubPrivate Sub munasiwetlik_Click()Form1.Caption = "欢迎使用智能计算器" Form1.HideForm3.ShowEnd SubPrivate Sub 继续_Click()Form1.Caption = "欢迎使用智能计算器"If Text3.T ext <> "" ThenText1.T ext = T ext3.T extText2.T ext = ""Text3.T ext = ""ElseForm1.Caption = "xataliq"Text3.T ext = "没有结果无法继续"End IfEnd SubPrivate Sub 加_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "错误"Text3.T ext = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a + bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfIf Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d + eText3.T ext = fEnd IfEnd SubPrivate Sub 减_Click()Form1.Caption = "欢迎使用智能计算器"If Check1.Value = "1" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "xataliq kuruldi"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "错误"Text3.Text = "运算数值不能为空"ElseDim d, e, f As Doubled = Val(Text1.T ext)e = Val(Text2.T ext)f = d - eText3.T ext = fEnd IfIf Check1.Value = "0" ThenElseIf Text1.T ext = "" Or Text2.T ext = "" Then Form1.Caption = "错误"Text3.T ext = "运算数值不能为空"ElseIf Text1.T ext = "" And Text2.T ext = "" Then Form1.Caption = "错误"Text3.T ext = "运算数值不能为空"ElseDim a, b, c As Doublea = Val(Text1.T ext)b = Val(Text2.T ext)c = a - bText3.T ext = cText1.T ext = ""Text2.T ext = ""End IfEnd SubPrivate Sub 清空_Click()Form1.Caption = "欢迎使用智能计算器"Text1.T ext = ""Text2.T ext = ""Text3.T ext = ""End Sub----------------------------------------------form2 ?? ???? ??????Private Sub Command1_Click() Form3.HideForm1.ShowForm1.T ext3.T ext = ""End SubPrivate Sub Command2_Click() EndEnd Sub。
VB 键盘常用代码
vbKeyL 76 字母 L 键
vbKeyM 77 字母 M 键
vbKeyN 78 字母 N 键
vbKeyO 79 字母 O 键
vbKeyP 80 字母 P 键
vbKeyQ 81 字母 Q 键
vbKeyR 82 字母 R 键
vbKeyS 83 字母 S 键
vbKeyF2 0x71 F2 功能键
vbKeyF3 0x72 F3 功能键
vbKeyF4 0x73 F4 功能键
vbKeyF5 0x74 F5 功能键
vbKeyF6 0x75 F6 功能键
vbKeyF7 0x76 F7 功能键
vbKeyF8 0x77 F8 功能键
vbKeyF9 0x78 F9 功能键
vbKeySnapshot 0x2C SnapShot 键
vbKeyInsert 0x2D INSERT 键
vbKeyDelete 0x2E DELETE 键
vbKeyHelp 0x2F HELP 键
vbKeyNumlock 0x90 NUM LOCK 键
vbKeyA 65 字母 A 键
vbKeyT 84 字母 T 键
vbKeyU 85 字母 U 键
vbKeyV 86 字母 V 键
vbKeyW 87 字母 W 键
vbKeyX 88 字母 X 键
vbKeyY 89 字母 Y 键
vbKeyZ 90 字母 Z 键
vbKey0 48 数字 0 键
vbKey1 49 数字 1 键
vbKeyReturn 0xD 回车键
vbKeyShift 0x10 SHIFT 键
vb源代码
第3章课前体验Private Sub Form_Click()For i = 1 To 10For j = 1 To iPrint "* ";Next jPrintNext iEnd Sub【例3-1】Private Sub Form_Click()c1$ = Chr$(13) + Chr$(10)msg1$ = "请输入您的名字: "msg2$ = "输入后按回车键"msg3$ = "或单击“确定”按钮"msg$ = msg1$ + c1$ + msg2$ + c1$ + msg3$name$ = InputBox(msg$, "InputBox 函数示例", "张三")Print name$End Sub【例3-2】Private Sub Form_Click()Msg1$=”Are you Continue to?”msg2$=”Operation Dialog Box”r=MsgBox(msg1$,34,msg2$)Print rEnd Sub【例3-3】编写程序,用MsgBox函数判断是否继续执行。
Private Sub Form_Click()msg$ = "请确认此数据是否正确"Title$ = "数据检查对话框"x = MsgBox(msg$, 19, Title$)If x = 6 ThenPrint x * xElseIf x = 7 ThenPrint "请重新输入"End IfEnd Sub【例3-5】Private Sub Form_Click()Print: PrintFontName = "隶书"FontSize = 16Print " 姓名"; Tab(8); "年龄"; Tab(16); "职务";Print Tab(24); "单位"; Tab(32); "籍贯"PrintPrint "吴大明"; Tab(8); 25; Tab(16); "职员"; Tab(24); "人事科"; Tab(32); "北京"Print "吴大明"; Tab(8); 25; Tab(16); "职员"; Tab(24); "人事科"; Tab(32); "北京"End Sub【例3-6】Private Sub Form_Click()X = InputBox("请输入成绩", "学生成绩录入", "00")Print xEnd Sub【例3-7】Private Sub Form_Click()Dim x As Single, y As Singlex=InputBox(“请输入x的值”)If x>0 Then y=1 ElseIf x=0 Then y=0 Else y=-1Print “x=”; x ,”y=” ; yEnd Sub【例3-8】Private Sub Form_Click()Dim msg, UserInputmsg = "请输入一个字母或0~9之间的数字."UserInput = InputBox(msg) ‘输入一个字母或数字If Not IsNumeric(UserInput) Then ‘判断是否是数字If Len(UserInput) = 1 Then ‘不是数字时,判断输入的字符串长度是否为1 Select Case Asc(UserInput) ‘判断输入字母的ASCII码值Case 60 To 90 '在60-90之间为大写字母msg = "你输入的是一个大写字母'"msg = msg & Chr(Asc(UserInput)) & "'。
VB 利用键盘模拟进行自动录入操作(完整模块代码)
Private Const VK_F5 = &H74
Private Const VK_F6 = &H75
Private Const VK_F7 = &H76
Private Const VK_F8 = &H77
Private Const VK_F9 = &H78
Private Const VK_NUMPAD1 = &H61
Private Const VK_NUMPAD2 = &H62
Private Const VK_NUMPAD3 = &H63
Private Const VK_NUMPAD4 = &H64
Private Const VK_NUMPAD5 = &
'▼插入消息队列。
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const VK_RSHIFT = &HA1
Private Const VK_SCROLL = &H91
Private Const VK_SELECT = &H29
Private Const VK_SEPARATOR = &H6C
Private Const VK_SHIFT = &H10
VB 类按键精灵源码2014
VB 类按键精灵源码2008-02-06 09:55:09| 分类:默认分类| 标签:|字号大中小订阅[源码]VB 类按键精灵源码窗体部分Private Sub Command1_Click()Script.AddItem ("坐标:" & MouseX.Text & "-" & MouseY.Text)End SubPrivate Sub Command2_Click()Script.AddItem ("鼠标:左键")End SubPrivate Sub Command3_Click()Script.AddItem ("鼠标:右键")End SubPrivate Sub Command4_Click()If KeyText.Text <> ""ThenScript.AddItem ("键盘:" & KeyText.Text)End IfEnd SubPrivate Sub Command5_Click()'=============================='功能:保存脚本'参数:script.txt -> 脚本文件名'==============================Dim i As IntegerOpen App.Path + "\script.txt"For Output As #1For i = 1 To Script.ListCountPrint #1, Script.List(i - 1) '这里使用 i-1 是因为 ListBox 控件是从 0 开始Next iClose #1MsgBox"保存完毕!", vbOKOnly, "保存脚本"End SubPrivate Sub Command6_Click()EndEnd SubPrivate Sub Command7_Click()Call StartEnd SubPrivate Sub Form_Load()'=============================='功能:读取脚本'参数:script.txt -> 脚本文件名'==============================Dim Scriptemp As StringIf Dir(App.Path + "\script.txt") = ""ThenOpen App.Path + "\script.txt"For Output As #1Close #1End IfOpen App.Path + "\script.txt"For Input As #1While Not EOF(1)Line Input #1, ScriptempScript.AddItem ScriptempWendClose #1End SubPrivate Sub KeyText_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCodeCase 112KeyText.Text = "F1"Case 113KeyText.Text = "F2"Case 114KeyText.Text = "F3"Case 115KeyText.Text = "F4"Case 116KeyText.Text = "F5"Case 117KeyText.Text = "F6"Case 118KeyText.Text = "F7"Case 119KeyText.Text = "F8"Case 120KeyText.Text = "F9"Case 121KeyText.Text = "F10"Case 122KeyText.Text = "F11"Case 123KeyText.Text = "F12"Case ElseKeyText.Text = Chr(KeyCode)End SelectEnd Sub'处理坐标是否超出一定长度Private Sub MouseX_Change()If Len(MouseX.Text) > 4 ThenMsgBox"坐标错误,请重新输入"MouseX.Text = "0"End IfEnd SubPrivate Sub MouseY_Change()If Len(MouseY.Text) > 4 ThenMsgBox"坐标错误,请重新输入"MouseY.Text = "0"End IfEnd Sub模块部分:Option ExplicitPublic Const MOUSEEVENTF_LEFTDOWN = &H2Public Const MOUSEEVENTF_LEFTUP = &H4Public Const MOUSEEVENTF_RIGHTDOWN = &H8Public Const MOUSEEVENTF_RIGHTUP = &H10Public Declare Function GetCursorPos Lib"user32" (lpPoint As POINTAPI) As Long'获得鼠标位置的 APIPublic Declare Function SetCursorPos Lib"user32" (ByVal X As Long, ByVal Y As Long) As Long'设置鼠标位置的 APIPublic Type POINTAPIX As LongY As LongEnd TypePublic Declare Sub mouse_event Lib"user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) '鼠标事件Public Declare Sub Sleep Lib"kernel32" (ByVal dwMilliseconds As Long) '程序延迟模块2Option Explicit'====================='功能:运行脚本'=====================Public Sub Start()Dim i As IntegerDim Script1 As StringDim ScriptLen As IntegerDim MousePos() As StringDim MouseCurPos As POINTAPIIf KeyVirtual.Script.ListCount = 0 ThenMsgBox"请添加脚本", vbOKOnly, "错误"Exit SubElseFor i = 0 To KeyVirtual.Script.ListCount - 1 '从 ListBox 的第一个开始Sleep 1000 '程序延迟 1 秒Script1 = KeyVirtual.Script.List(i) '获得脚本ScriptLen = Len(Script1) '获得脚本字符长度Select Case Mid(Script1, 1, 2) '选择脚本字符前两个字符Case"坐标"Script1 = Mid(Script1, 4, ScriptLen - 3) '获得后面的字符MousePos = Split(Script1, "-") '通过 - 来分割获得坐标,并放到 MousePos(数组)里面SetCursorPos CLng(MousePos(0)), CLng(MousePos(1)) '设置鼠标位置Case"鼠标"GetCursorPos MouseCurPos '获得鼠标坐标到 MousePos(数组)If Mid(Script1, 4, 2) = "左键"Thenmouse_event MOUSEEVENTF_LEFTDOWN, MouseCurPos.X, MouseCurPos.Y, 0, 0 '设置鼠标左键按下mouse_event MOUSEEVENTF_LEFTUP, MouseCurPos.X, MouseCurPos.Y, 0, 0 '设置鼠标左键弹出Elsemouse_event MOUSEEVENTF_RIGHTDOWN, MouseCurPos.X, MouseCurPos.Y, 0, 0 '设置鼠标右键按下mouse_event MOUSEEVENTF_RIGHTUP, MouseCurPos.X, MouseCurPos.Y, 0, 0 '设置鼠标右键弹出End IfCase"键盘"SendKeys Mid(Script1, 4, ScriptLen - 3) '发送键盘字符End SelectNext iEnd IfEnd Sub。
自制小键盘(vb源代码)
自制小键盘(vb源代码)'API声明Private Declare Function SetWindowPos& Lib "user32" (ByV al hwnd As Long, ByV al hWndInsertAfter As Long, ByV al X As Long, ByV al Y As Long, ByV al cx As Long, ByV al cy As Long, ByV al wFlags As Long)Dim MoveScreen As Boolean'鼠标位置Dim MousX As IntegerDim MousY As Integer'窗体位置Dim CurrX As IntegerDim CurrY As IntegerPrivate Sub Command1_Click()'Shift键If Command1.BackColor = &H8000000F ThenCommand1.BackColor = &H8000000DElseCommand1.BackColor = &H8000000FEnd IfEnd Sub'退格键Private Sub Command10_Click()Form2.ActiveControl.SetFocusSendKeys ("{BS}")End Sub'大小写转换键Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Command2.BackColor = &H8000000F Then Command2.BackColor = vbGreenElseCommand2.BackColor = &H8000000FEnd IfEnd Sub'TAB键Private Sub Command3_Click()Form2.ActiveControl.SetFocusSendKeys ("{tab}")End Sub'Ins键Private Sub Command4_Click()Form2.ActiveControl.SetFocusSendKeys ("{INSERT}")End Sub'Del键Private Sub Command5_Click()Form2.ActiveControl.SetFocusSendKeys ("{DEL}")End Sub'空格键Private Sub Command6_Click()Form2.ActiveControl.SetFocusSendKeys ("{BREAK} ")End Sub'Esc键Private Sub Command7_Click()Form2.ActiveControl.SetFocusSendKeys ("{Esc}")End Sub'普通键Private Sub Command8_Click(Index As Integer)Dim keyxFor i = 0 To 18If i = Index ThenIf Command1.BackColor = &H8000000D Thenkeyx = "{" & Mid(Command8(i).Caption, 1, 1) & "}": Command1.BackColor = &H8000000FElsekeyx = Mid(Command8(i).Caption, 3, 1)End IfEnd IfNext iSelect Case IndexCase 19If Command1.BackColor = &H8000000D Thenkeyx = "——": Command1.BackColor = &H8000000FElsekeyx = Mid(Command8(Index).Caption, 3, 1)End IfCase 20If Command1.BackColor = &H8000000D Thenkeyx = Mid(Command8(Index).Caption, 1, 1): Command1.BackColor = &H8000000F Elsekeyx = Mid(Command8(Index).Caption, 4, 1)End IfEnd SelectFor i = 21 To 46If i = Index ThenIf Command1.BackColor = &H8000000D And Command2.BackColor = vbGreen Thenkeyx = Mid(Command8(i).Caption, 3, 1): Command1.BackColor = &H8000000FElseIf Command1.BackColor = &H8000000D And Command2.BackColor = &H8000000F Then keyx = Mid(Command8(i).Caption, 1, 1): Command1.BackColor = &H8000000FElseIf Command1.BackColor = &H8000000F And Command2.BackColor = &H8000000F Then keyx = Mid(Command8(i).Caption, 3, 1)Elsekeyx = Mid(Command8(i).Caption, 1, 1)End IfEnd IfNext iForm2.ActiveControl.SetFocusSendKeys keyxEnd Sub'回车键Private Sub Command9_Click()Form2.ActiveControl.SetFocusSendKeys ("{ENTER}")End Sub'让小键盘在最前面Private Sub Form_Load()Me.Left = Screen.Width * 0.75Me.Top = Screen.Height * 0.75rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)Command1.BackColor = &H8000000FCommand2.BackColor = &H8000000FFor i = 0 To 46Command8(i).MouseIcon = LoadPicture(App.Path & ("\harrow.cur"))Command8(i).MousePointer = 99Next iEnd Sub'移动没有标题的小键盘Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 1 Then'标示为移动状态MoveScreen = True'得到鼠标在窗体上的位置(相对与窗体内部坐标)MousX = XMousY = YEnd IfIf Button = 2 Then Unload Form1End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '如果处于鼠标左键按下的状态,即MoveScreen = True时If MoveScreen Then'计算新的窗体坐标值'仔细想一下,看看是不是这样CurrX = Form1.Left - MousX + XCurrY = Form1.T op - MousY + Y'移动窗体到新的位置Form1.Move CurrX, CurrYEnd IfEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) MoveScreen = False End Sub'这个可有可无,做这个是为了好看点Private Sub Timer1_Timer()If Label1.ForeColor = &HFFFF00 ThenLabel1.ForeColor = &HFF&ElseLabel1.ForeColor = &HFFFF00End IfEnd Sub下面是form2中的代码Private Sub Form_Unload(Cancel As Integer)EndEnd SubPrivate Sub form_load()Form1.ShowEnd Sub本例在VB6+xp2中通过。
VB精典实用源代码(详细))
个人收藏的VB精典实用源代码。
若朋友您想要问如何才能学好vb,或者入门需要看什么教材一类的问题,建议你抱着一颗刻苦钻研的心去面对这门学问,多动脑,少提问,遇到不知道的,多查资料,多看看帖子,或者用断点来亲自试验。
实在不会了,请在此贴中查找您的常见问题,如果还没有,那请您发出新贴,向各位高手讨教:)查找方法:按ctrl+f,输入要查找的问题关键字即可每个问题中间用///分隔,这只是一部分最常见到的问题,以后会逐渐更新。
////////////////////////////////////////////////////////////////////////////////////如何用VB建立快捷方式Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As LongSub Command1_Click()Dim lReturn As Long'添加到桌面lReturn = fCreateShellLink("..\..\Desktop", "Shortcut to Calculator", "c:\windows\calc.exe", "")'添加到程序组lReturn = fCreateShellLink("", "Shortcut to Calculator", "c:\windows\calc.exe", "")'添加到启动组lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", "c:\windows\calc.exe", "")End Sub//////////////////////////////////////////////////////////////////////////////////// 如何让程序在Windows 启动时自动执行?有以下二个方法:方法1: 直接将快捷方式放到启动群组中。
用VB制作外挂
用VB制作外挂用VB制作外挂1.鼠标模拟技术几乎所有的游戏中都使用了鼠标来改变角色的位置和方向,玩家仅用一个小小的鼠标,就可以使角色畅游天下。
那么,我们如何实现在没有玩家的参与下角色也可以自动行走呢。
其实实现这个并不难,仅仅几个Windows API函数就可以搞定,让我们先来认识认识这些API函数。
(1) 模拟鼠标动作API函数mouse_event,它可以实现模拟鼠标按下和放开等动作。
VOID mouse_event(DWORD dwFlags, // 鼠标动作标识。
DWORD dx, // 鼠标水平方向位置。
DWORD dy, // 鼠标垂直方向位置。
DWORD dwData, // 鼠标轮子转动的数量。
DWORD dwExtraInfo // 一个关联鼠标动作辅加信息。
);其中,dwFlags表示了各种各样的鼠标动作和点击活动,它的常用取值如下:MOUSEEVENTF_MOVE 表示模拟鼠标移动事件。
MOUSEEVENTF_LEFTDOWN 表示模拟按下鼠标左键。
MOUSEEVENTF_LEFTUP 表示模拟放开鼠标左键。
MOUSEEVENTF_RIGHTDOWN 表示模拟按下鼠标右键。
MOUSEEVENTF_RIGHTUP 表示模拟放开鼠标右键。
MOUSEEVENTF_MIDDLEDOWN 表示模拟按下鼠标中键。
MOUSEEVENTF_MIDDLEUP 表示模拟放开鼠标中键。
(2)、设置和获取当前鼠标位置的API函数。
获取当前鼠标位置使用GetCursorPos()函数,设置当前鼠标位置使用SetCursorPos()函数。
BOOL GetCursorPos(LPPOINT lpPoint // 返回鼠标的当前位置。
);BOOL SetCursorPos(int X, // 鼠标的水平方向位置。
int Y //鼠标的垂直方向位置。
);通常游戏角色的行走都是通过鼠标移动至目的地,然后按一下鼠标的按钮就搞定了。
VB键盘常量大全个虚拟键码
Public Const VK_LBUTTON = &H1 Public Const VK_RBUTTON = &H2 Public Const VK_CANCEL = &H3 Public Const VK_MBUTTON = &H4 Public Const VK_BACK = &H8 Public Const VK_TAB = &H9 Public Const VK_CLEAR = &HC Public Const VK_RETURN = &HD Public Const VK_SHIFT = &H10 Public Const VK_CONTROL = &H11 Public Const VK_MENU = &H12 Public Const VK_PAUSE = &H13 Public Const VK_CAPITAL = &H14 Public Const VK_ESCAPE = &H1B Public Const VK_SPACE = &H20 Public Const VK_PRIOR = &H21 Public Const VK_NEXT = &H22 Public Const VK_END = &H23 Public Const VK_HOME = &H24 Public Const VK_LEFT = &H25 Public Const VK_UP = &H26 Public Const VK_RIGHT = &H27 Public Const VK_DOWN = &H28 Public Const VK_Select = &H29 Public Const VK_PRINT = &H2A Public Const VK_EXECUTE = &H2BPublic Const VK_SNAPSHOT = &H2C Public Const VK_Insert = &H2D Public Const VK_Delete = &H2E Public Const VK_HELP = &H2F Public Const VK_0 = &H30Public Const VK_1 = &H31Public Const VK_2 = &H32Public Const VK_3 = &H33Public Const VK_4 = &H34Public Const VK_5 = &H35Public Const VK_6 = &H36Public Const VK_7 = &H37Public Const VK_8 = &H38Public Const VK_9 = &H39Public Const VK_A = &H41Public Const VK_B = &H42Public Const VK_C = &H43Public Const VK_D = &H44Public Const VK_E = &H45Public Const VK_F = &H46Public Const VK_G = &H47Public Const VK_H = &H48Public Const VK_I = &H49Public Const VK_J = &H4APublic Const VK_K = &H4BPublic Const VK_L = &H4CPublic Const VK_M = &H4DPublic Const VK_N = &H4EPublic Const VK_O = &H4FPublic Const VK_P = &H50Public Const VK_Q = &H51Public Const VK_R = &H52Public Const VK_S = &H53Public Const VK_T = &H54Public Const VK_U = &H55Public Const VK_V = &H56Public Const VK_W = &H57Public Const VK_X = &H58Public Const VK_Y = &H59Public Const VK_Z = &H5APublic Const VK_STARTKEY = &H5B Public Const VK_CONTEXTKEY = &H5D Public Const VK_NUMPAD0 = &H60 Public Const VK_NUMPAD1 = &H61 Public Const VK_NUMPAD2 = &H62 Public Const VK_NUMPAD3 = &H63 Public Const VK_NUMPAD4 = &H64 Public Const VK_NUMPAD5 = &H65 Public Const VK_NUMPAD6 = &H66 Public Const VK_NUMPAD7 = &H67 Public Const VK_NUMPAD8 = &H68 Public Const VK_NUMPAD9 = &H69Public Const VK_MULTIPLY = &H6A Public Const VK_ADD = &H6B Public Const VK_SEPARATOR = &H6C Public Const VK_SUBTRACT = &H6D Public Const VK_DECIMAL = &H6E Public Const VK_DIVIDE = &H6F Public Const VK_F1 = &H70Public Const VK_F2 = &H71Public Const VK_F3 = &H72Public Const VK_F4 = &H73Public Const VK_F5 = &H74Public Const VK_F6 = &H75Public Const VK_F7 = &H76Public Const VK_F8 = &H77Public Const VK_F9 = &H78Public Const VK_F10 = &H79 Public Const VK_F11 = &H7A Public Const VK_F12 = &H7B Public Const VK_F13 = &H7C Public Const VK_F14 = &H7D Public Const VK_F15 = &H7E Public Const VK_F16 = &H7F Public Const VK_F17 = &H80 Public Const VK_F18 = &H81 Public Const VK_F19 = &H82 Public Const VK_F20 = &H83Public Const VK_F21 = &H84Public Const VK_F22 = &H85Public Const VK_F23 = &H86Public Const VK_F24 = &H87Public Const VK_NUMLOCK = &H90 Public Const VK_OEM_SCROLL = &H91 Public Const VK_OEM_1 = &HBA Public Const VK_OEM_PLUS = &HBB Public Const VK_OEM_COMMA = &HBC Public Const VK_OEM_MINUS = &HBD Public Const VK_OEM_PERIOD = &HBE Public Const VK_OEM_2 = &HBF Public Const VK_OEM_3 = &HC0 Public Const VK_OEM_4 = &HDB Public Const VK_OEM_5 = &HDC Public Const VK_OEM_6 = &HDD Public Const VK_OEM_7 = &HDE Public Const VK_OEM_8 = &HDF Public Const VK_ICO_F17 = &HE0 Public Const VK_ICO_F18 = &HE1 Public Const VK_OEM102 = &HE2 Public Const VK_ICO_HELP = &HE3 Public Const VK_ICO_00 = &HE4 Public Const VK_ICO_CLEAR = &HE6 Public Const VK_OEM_RESET = &HE9 Public Const VK_OEM_JUMP = &HEAPublic Const VK_OEM_PA1 = &HEBPublic Const VK_OEM_PA2 = &HECPublic Const VK_OEM_PA3 = &HEDPublic Const VK_OEM_WSCTRL = &HEEPublic Const VK_OEM_CUSEL = &HEFPublic Const VK_OEM_ATTN = &HF0Public Const VK_OEM_FINNISH = &HF1Public Const VK_OEM_COPY = &HF2Public Const VK_OEM_AUTO = &HF3Public Const VK_OEM_ENLW = &HF4Public Const VK_OEM_BACKTAB = &HF5Public Const VK_ATTN = &HF6Public Const VK_CRSEL = &HF7Public Const VK_EXSEL = &HF8Public Const VK_EREOF = &HF9Public Const VK_PLAY = &HFAPublic Const VK_ZOOM = &HFBPublic Const VK_NONAME = &HFCPublic Const VK_PA1 = &HFDPublic Const VK_OEM_CLEAR = &HFE虚拟键码虚拟键码保存在WM_KEYDOWN、WM_KEYUP、WM_SYSKEYDOWN和WM_SYSKEYUP 讯息的wParam参数中。
VB键盘常用代码一览表
vbKeyC 67 字母 C 键
vbKeyD 68 字母 D 键
vbKeyE 69 字母 E 键
vbKeyF 70 字母 F 键
vbKeyG 71 字母 G 键
vbKeyH 72 字母 H 键
vbKeyI 73 字母 I 键
vbKeyJ 74 字母 J 键
vbKeyNumpad0 0x60 小键盘 0 键
vbKeyNumpad1 0x61 小键盘 1 键
vbKeyNumpad2 0x62 小键盘 2 键
vbKeyNumpad3 0x63 小键盘 3 键
vbKeyNumpad4 0x64 小键盘 4 键
vbKeyNumpad5 0x65 小键盘 5 键
vbKey2 50 数字 2 键
vbKey3 51 数字 3 键
vbKey4 52 数字 4 键
vbKey5 53 数字 5 键
vbKey6 54 数字 6 键
vbKey7 55 数字 7 键
vbKey8 56 数字 8 键
vbKey9 57 数字 9 键
vbKeyF1 0x70 F1 ቤተ መጻሕፍቲ ባይዱ能键
vbKeyEscape 0x1B ESC 键
vbKeySpace 0x20 空格键
vbKeyPageUp 0x21 Page Up 键
vbKeyPageDown 0x22 Page Down 键
vbKeyEnd 0x23 END 键
vbKeyHome 0x24 HOME 键
vbKeyLeft 0x25 光标左键
vbKeyNumpad6 0x66 小键盘 6 键
VB模拟按键终极教程
VB模拟按键终极教程VB(Visual Basic)是一种可视化的编程语言,在Windows操作系统中得到广泛应用。
VB可以通过模拟按键实现自动化操作,比如自动填写表单、自动点击按钮等。
本教程将详细介绍如何使用VB来模拟按键操作的终极方法。
首先,我们需要创建一个新的VB项目。
打开VB开发环境,点击“新建项目”并选择“Windows桌面向导”。
在下一步中,选择“Windows窗体应用程序”并命名项目。
点击“确定”开始创建项目。
```Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _ByVal bScan As Byte, _ByVal dwFlags As Long, _ByVal dwExtraInfo As Long)Private Const KEYEVENTF_KEYUP = &H2```上述代码声明了一个名为keybd_event的函数和一个名为KEYEVENTF_KEYUP的常量。
keybd_event函数用于模拟按键操作,KEYEVENTF_KEYUP常量用于指定按键的释放事件。
然后,在Form_Load事件处理程序中添加以下代码,实现模拟按键操作:```Private Sub Form_Loadkeybd_event(VBKeyLMenu, 0, 0, 0) '按下左Alt键keybd_event(Keys.F, 0, 0, 0) '按下F键keybd_event(Keys.F, 0, KEYEVENTF_KEYUP, 0) '释放F键keybd_event(VBKeyLMenu, 0, KEYEVENTF_KEYUP, 0) '释放左Alt键End Sub```上述代码会在窗体加载时模拟按下左Alt键和F键,并在F键释放后释放左Alt键。
最后,我们需要在按钮的Click事件处理程序中添加代码来触发模拟按键操作。
vb.net开发实例源代码
开发实例源代码
以下是一个简单的 开发实例源代码,用于创建一个 Windows 应用程序,显示一个带有按钮的窗口,当点击按钮时会弹出一个消息框。
```vb
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show("你点击了按钮!")
End Sub
End Class
```
在这个示例中,我们创建了一个名为 `Form1` 的类,其中包含一个名为 `Button1` 的按钮和一个名为 `Button1_Click` 的事件处理程序。
当点击按钮时,`Button1_Click` 事件处理程序将执行,弹出一个消息框显示 "你点击了按钮!"。
这只是一个简单的示例,你可以根据自己的需求进行扩展和修改。
提供了丰富的工具和功能,帮助你创建各种类型的应用程序,包括 Windows 桌面应用程序、Web 应用程序、移动应用程序等。
如果你有特定的需求或想要进一步学习 开发,我建议你参考相关的教程、书籍或在线资源,以获取更详细和深入的信息。
vb源程序代码
Vb源代码(周至县第五中学710402 数学组唐永鸽)1 Private Sub Form_Click()Dim n As Integer, f1 As Double, f2 As Double, f3 As DoubleDim i As Integern = Val(InputBox("输入要输出的项数:", "输出斐波那契数列", 20)) f1 = 0f2 = 1Print Tab(8); f1Print Tab(8); f2For i = 3 To nf3 = f2 + f1Print Tab(8); f3f1 = f2f2 = f3NextEnd Sub2 Private Sub Form_Click()Dim n As Integer, f1 As Doublen = 1For n = 1 To 66f1 = 15 * nPrint f1NextEnd Sub3 Private Sub Form_Click()Dim a1 As Double, n As Double, i As Integera1 = V al(InputBox("请输入第1个数", "找最大数"))Print Tab(5); a1For i = 2 To 5n = Val(InputBox("请输入第" & i & "个数"))Print Tab(5); nIf n > a1 Then a1 = nNextPrint ""Print "最大数为"; a1End Sub4、Private Sub Form_Click()Dim year As Longyear = InputBox("请输入年份")If year Mod 4 = 0 ThenIf year Mod 100 = 0 ThenIf year Mod 400 = 0 ThenPrint year; "年是闰年"ElsePrint year; "不年是闰年"End IfElsePrint year; "年是闰年"End IfElsePrint year; "不年是闰年"End IfEnd Sub5、Private Sub form_Click() Dim year As LongFor year = 2000 To 2500If year Mod 4 = 0 ThenIf year Mod 100 = 0 ThenIf year Mod 400 = 0 ThenPrint year; "年是闰年", ElsePrint year; "年不是闰年", End IfElsePrint year; "年是闰年", End IfElsePrint year; "年不是闰年",End IfNextEnd Sub6、Option Base 1Private Sub Form_Click()Const n = 10Dim a(n) As SingleMax = 0k = 0For i = 1 To na(i) = Val(InputBox("请输入第" & i & "个数", "找最大数"))Print Tab(5); "第" & i & "个数为:"; a(i)Next iFor i = 1 To nIf Max < a(i) ThenMax = a(i)k = iEnd IfNextPrintPrint "最大数为第" & k & "个数"; MaxEnd Sub7 、方法1、 Private Sub Form_Click()Dim n As Integer, f1 As Integer, f2 As Integer, f3 As Integer For n = 100 To 999f1 = Int(n / 100)f2 = Int(n / 10) Mod 10f3 = n Mod 10If f1 ^ 3 + f2 ^ 3 + f3 ^ 3 = n ThenPrint n; "为水仙花数"End IfNextEnd Sub方法2、Private Sub Form_Click()Dim n As Integer, f1 As Integer, f2 As Integer, f3 As Integer n = 100Do While n <= 999f1 = Int(n / 100)f2 = Int(n / 10) Mod 10f3 = n Mod 10If f1 ^ 3 + f2 ^ 3 + f3 ^ 3 = n ThenPrint n; "为水仙花数"End Ifn = n + 1LoopEnd Sub8 、 Private Sub Form_Click()Dim n As Integer, s As Integern = 1s = 0Dos = s + nn = n + 1Loop While s <= 200n = n - 2Print nEnd Sub9、二分法方法1、Public Function f(x As Double) As Doublef = x ^ 3 - x - 1End FunctionPrivate Sub command1_Click()Dim a As Double, b As Double, p As Singlea = 1b = 1.5p = 0.00001DoIf f((a + b) / 2) = 0 ThenExit DoElseIf f(a) * f((a + b) / 2) < 0 Thenb = (a + b) / 2Elsea = (a + b) / 2End IfEnd IfLoop While b - a >= pLabel1.Caption = "方程的根是" & (a + b) / 2End SubPrivate Sub Command2_Click()Label2.Caption = "求方程 f = x ^ 3 - x - 1的近似解" End Sub方法2、Private Sub Command1_Click()a = Val(Text1.Text)b = Val(Text2.Text)e = Val(Text3.Text)fa = (a * a - 1) * a - 1fb = (b * b - 1) * b - 1If fa * fb >= 0 ThenText4.Text = "求解范围错!"ElseDox = (a + b) / 2f = (x * x - 1) * x - 1If f * fa > 0 Thena = x: fa = fElseb = x: fb = fEnd IfLoop Until f = 0 Or Abs(b - a) < eText4.Text = (a + b) / 2End IfEnd Sub10、冒泡排序Private Sub Command1_Click()Dim C(6) As DoubleFor n = 1 To 6C(n) = InputBox("输入需要排序的数", "6个数的冒泡排序", "") Next nFor i = 1 To 6For j = 6 To i Step -1If C(j) < C(j - 1) Thena = C(j): C(j) = C(j - 1): C(j - 1) = aEnd IfNext jNext iFor i = 1 To 6Print "", C(i)Next iEnd Sub11、求12+22+32+…+1002的算法Private Sub Form_Load()Dim n As Long, s As Longn = InputBox("请输入 n:", "从1到n求平方和", 100)s = 0i = 1While i <= ns = s + i * ii = i + 1WendForm1.ShowPrint "", "1 到 "; n; " 的平方和是:"; sEnd Sub12、辗转相除法求最大公因数Private Sub Form_Click()a = InputBox("请输入一个整数")b = InputBox("请输入一个整数")n1 = Abs(a)n2 = Abs(b)Do While n1 Mod n2 <> 0tt = n1 Mod n2n1 = n2n2 = ttLoopLabel1.Caption = a & "和" & b & "的最大公因数为" & n2End Sub13、用秦九韶算法求多项式的值Private Sub Command1_Click()Dim C(5) As Doublex = InputBox("请输入求值数", "")C(0) = -0.8: C(1) = 1.7: C(2) = -2.6: C(3) = 3.5: C(4) = 2: C(5) = 5 n = 1v = C(5)While n <= 5v = v * x + C(5 - n)n = n + 1WendPrint "所求的值是"; vEnd Sub14 .判断素数Private Sub Form_Click()Dim n As LongDim i As LongDim r As Singlen = Val(InputBox("请输入一个数", "判断素数"))For i = 2 To n - 1r = n Mod iIf r = 0 ThenPrintPrint n; "不是素数"GoTo 17End IfNextPrintPrint n; "为素数"17 End Sub15Private Sub Form_Click()Dim i As Integer, sum As Doublesum = 1For i = 1 To 64sum = sum + 2 ^ iNext iPrint sumEnd Sub16、猜字游戏Private Sub Command1_Click()RandomizeDim Num As LongDim RightAnswer As BooleanDim InputNum As LongText1.Text = ""Num = Int(Rnd * 10) + 1RightAnswer = FalseText1.Text = Text1.Text + "Here's a number between 1 and 10. Can you guess it?" + vbNewLineWhile RightAnswer = FalseInputNum = InputBox("Enter a number")If InputNum = Num ThenText1.Text = Text1.Text & InputNum & " " & "You guessed it!" & vbNewLineRightAnswer = TrueElseIf InputNum < Num ThenText1.Text = Text1.Text & InputNum & " " & "Too Small" & vbNewLineElseIf InputNum > Num ThenText1.Text = Text1.Text & InputNum & " " & "Too Large" & vbNewLineEnd IfWendEnd Sub17、石头、剪刀、布Private Sub Form_Activate()Option1.Caption = "石头"Option2.Caption = "剪刀"Option3.Caption = "布"Option1.Value = FalseOption2.Value = FalseOption3.Value = FalseEnd SubPrivate Sub Option1_Click()RandomizeSelect Case Int(3 * Rnd)Case 0: MsgBox "对方也出石头!继续!"Case 1: MsgBox "哈哈!你赢了!对方出的是剪刀!奖励你一个苹果!"Case 2: MsgBox "你输了!对方出的是布哦!不好意思,苹果给对方了哈!" End SelectOption1.Value = FalseEnd SubPrivate Sub Option2_Click()RandomizeSelect Case Int(3 * Rnd)Case 0: MsgBox "你输了!对方出的是石头哦!不好意思,苹果给对方了哈!" Case 1: MsgBox "对方也出剪刀!继续!"Case 2: MsgBox "哈哈!你赢了!对方出的是布!奖励你一个苹果!"End SelectOption2.Value = FalseEnd SubPrivate Sub Option3_Click()RandomizeSelect Case Int(3 * Rnd)Case 0: MsgBox "哈哈!你赢了!对方出的是石头!奖励你一个苹果!"Case 1: MsgBox "你输了!对方出的是剪刀哦!不好意思,苹果给对方了哈!" Case 2: MsgBox "对方也出布!继续!"End SelectOption3.Value = FalseEnd Sub18、选择题计分程序Private Sub Command1_Click() '提交按钮CommandButton1Dim sum As Integersum = 0If Text1.Text = "A" Thensum = sum + 5Image1.Picture = LoadPicture("E:\课件素材\图片\对号.jpg")ElseImage1.Picture = LoadPicture("E:\课件素材\图片\错号.jpg")End IfIf Text2.Text = "B" Thensum = sum + 5Image2.Picture = LoadPicture("E:\课件素材\图片\对号 - 副本.jpg") ElseImage2.Picture = LoadPicture("E:\课件素材\图片\错号 - 副本.jpg") End IfText3.Text = "您的最后得分是:" & sum & "分" & vbNewLineIf sum <= 5 ThenText3.Text = Text3.Text + "加油啊!"ElseText3.Text = Text3.Text + "恭喜您!及格了!"End IfEnd SubPrivate Sub Command2_Click()Text1.Text = ""Image1.Picture = LoadPicture()Text2.Text = ""Image2.Picture = LoadPicture()Text3.Text = ""End Sub18、韩信点兵Private Sub Command1_Click()Dim X As Integer, Y As IntegerX = 1: Y = 0DoIf X Mod 3 = 1 ThenIf X Mod 5 = 2 ThenIf X Mod 7 = 4 ThenIf X Mod 13 = 6 ThenIf X Mod 17 = 8 Then Y = X End IfEnd IfEnd IfEnd IfX = X + 1Loop Until Y > 0Print "韩信统御士兵数:"; YEnd SubPrivate Sub Form_Click()k = 0s = 0100k = k + 1s = s + kIf k < 100 Then GoTo 100Print sEnd Sub。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
‘这是程序的核心代码,其他一些辅助的模块代码,请进VB源代码相关Private Sub Command1_Click()If (Text1.Text Like "[a-z]" Or Text1.Text Like "[0-9]" Or Text1.Text = "ENTER" Or Text1.Text = "enter" Or Text1.Text = "Enter") And Text2.Text <> "" ThenTimer1.Enabled = TrueText1.Enabled = FalseText2.Enabled = FalseCommand1.Enabled = FalseCommand2.Enabled = TrueElse: MsgBox "请仔细阅读提示,然后再输入!", , "提示"End IfEnd SubPrivate Sub Label4_Click()ShellExecute 0, "open", "/u/2461456205", vbNullString, vbNullString, 3 End SubPrivate Sub Text1_Change()Text1.MaxLength = 5End SubPrivate Sub Text2_KeyPress(KeyAscii As Integer)If KeyAscii <> 8 And KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then KeyAscii = 0End SubPrivate Sub Command2_Click()Timer1.Enabled = FalseCommand1.Enabled = TrueCommand2.Enabled = FalseText1.Enabled = TrueText2.Enabled = TrueEnd SubPrivate Sub Form_Load()If Dir(App.Path & "\skin.urf") <> "" ThenDim bRes As BooleanbRes = SkinStart(App.Path & "\skin.urf", 2, "RQPJNW0N0V2QRMAP1KXVBHHDUVVQGUXR", 1, 0, 0)End IfLabel3.Caption = "1、键值:[小写a-z][0-9]" & vbCrLf & " [enter][ENTER][Enter]" & vbCrLf & "2、次数:只能是数字" & vbCrLf & "3、操作:最小化时会自动退至托盘后台执行!"Call CreatTray(Me, "显示/隐藏界面", "", "", 1)Timer1.Enabled = FalseCommand2.Enabled = FalseEnd SubPrivate Sub timer1_timer()On Error Resume NextIf Text1.Text = "a" ThenIf GetAsyncKeyState(vbKeyA) Then Dim i As IntegerFor i = 1 To Text2.TextSendKeys "{a}"Next iEnd IfElseIf Text1.Text = "b" ThenIf GetAsyncKeyState(vbKeyB) Then For i = 1 To Text2.TextSendKeys "{b}"Next iEnd IfElseIf Text1.Text = "c" ThenIf GetAsyncKeyState(vbKeyC) Then For i = 1 To Text2.TextSendKeys "{c}"Next iEnd IfElseIf Text1.Text = "d" ThenIf GetAsyncKeyState(vbKeyD) Then For i = 1 To Text2.TextSendKeys "{d}"Next iEnd IfElseIf Text1.Text = "e" ThenIf GetAsyncKeyState(vbKeyE) Then For i = 1 To Text2.TextSendKeys "{e}"Next iEnd IfElseIf Text1.Text = "f" ThenIf GetAsyncKeyState(vbKeyF) Then For i = 1 To Text2.TextSendKeys "{f}"Next iEnd IfElseIf Text1.Text = "g" ThenIf GetAsyncKeyState(vbKeyG) Then For i = 1 To Text2.TextSendKeys "{g}"Next iEnd IfElseIf Text1.Text = "h" ThenIf GetAsyncKeyState(vbKeyH) Then For i = 1 To Text2.TextSendKeys "{h}"Next iEnd IfElseIf Text1.Text = "i" ThenIf GetAsyncKeyState(vbKeyI) Then For i = 1 To Text2.TextSendKeys "{i}"Next iEnd IfElseIf Text1.Text = "j" ThenIf GetAsyncKeyState(vbKeyJ) Then For i = 1 To Text2.TextSendKeys "{j}"Next iEnd IfElseIf Text1.Text = "k" ThenIf GetAsyncKeyState(vbKeyK) Then For i = 1 To Text2.TextSendKeys "{k}"Next iEnd IfElseIf Text1.Text = "l" ThenIf GetAsyncKeyState(vbKeyL) Then For i = 1 To Text2.TextSendKeys "{l}"Next iEnd IfElseIf Text1.Text = "m" ThenIf GetAsyncKeyState(vbKeyM) Then For i = 1 To Text2.TextSendKeys "{m}"Next iEnd IfElseIf Text1.Text = "n" ThenIf GetAsyncKeyState(vbKeyN) Then For i = 1 To Text2.TextSendKeys "{n}"Next iEnd IfElseIf Text1.Text = "o" ThenIf GetAsyncKeyState(vbKeyO) Then For i = 1 To Text2.TextSendKeys "{o}"Next iEnd IfElseIf Text1.Text = "p" ThenIf GetAsyncKeyState(vbKeyP) Then For i = 1 To Text2.TextSendKeys "{p}"Next iEnd IfElseIf Text1.Text = "q" ThenIf GetAsyncKeyState(vbKeyQ) Then For i = 1 To Text2.TextSendKeys "{q}"Next iEnd IfElseIf Text1.Text = "r" ThenIf GetAsyncKeyState(vbKeyR) Then For i = 1 To Text2.TextSendKeys "{r}"Next iEnd IfElseIf Text1.Text = "s" ThenIf GetAsyncKeyState(vbKeyS) Then For i = 1 To Text2.TextSendKeys "{s}"Next iEnd IfElseIf Text1.Text = "t" ThenIf GetAsyncKeyState(vbKeyT) Then For i = 1 To Text2.TextSendKeys "{t}"Next iEnd IfElseIf Text1.Text = "u" ThenIf GetAsyncKeyState(vbKeyU) Then For i = 1 To Text2.TextSendKeys "{u}"Next iEnd IfElseIf Text1.Text = "v" ThenIf GetAsyncKeyState(vbKeyV) Then For i = 1 To Text2.TextSendKeys "{v}"Next iEnd IfElseIf Text1.Text = "w" ThenIf GetAsyncKeyState(vbKeyW) Then For i = 1 To Text2.TextSendKeys "{w}"Next iEnd IfElseIf Text1.Text = "x" ThenIf GetAsyncKeyState(vbKeyX) Then For i = 1 To Text2.TextSendKeys "{x}"Next iEnd IfElseIf Text1.Text = "y" ThenIf GetAsyncKeyState(vbKeyY) Then For i = 1 To Text2.TextSendKeys "{y}"Next iEnd IfElseIf Text1.Text = "z" ThenIf GetAsyncKeyState(vbKeyZ) Then For i = 1 To Text2.TextSendKeys "{z}"Next iEnd IfElseIf Text1.Text = "1" ThenIf GetAsyncKeyState(vbKey1) Then For i = 1 To Text2.TextSendKeys "{1}"Next iEnd IfElseIf Text1.Text = "2" ThenIf GetAsyncKeyState(vbKey2) Then For i = 1 To Text2.TextSendKeys "{2}"Next iEnd IfElseIf Text1.Text = "3" ThenIf GetAsyncKeyState(vbKey3) Then For i = 1 To Text2.TextSendKeys "{3}"Next iEnd IfElseIf Text1.Text = "4" ThenIf GetAsyncKeyState(vbKey4) ThenFor i = 1 To Text2.TextSendKeys "{4}"Next iEnd IfElseIf Text1.Text = "5" ThenIf GetAsyncKeyState(vbKey5) ThenFor i = 1 To Text2.TextSendKeys "{5}"Next iEnd IfElseIf Text1.Text = "6" ThenIf GetAsyncKeyState(vbKey6) ThenFor i = 1 To Text2.TextSendKeys "{6}"Next iEnd IfElseIf Text1.Text = "7" ThenIf GetAsyncKeyState(vbKey7) ThenFor i = 1 To Text2.TextSendKeys "{7}"Next iEnd IfElseIf Text1.Text = "8" ThenIf GetAsyncKeyState(vbKey8) ThenFor i = 1 To Text2.TextSendKeys "{8}"Next iEnd IfElseIf Text1.Text = "9" ThenIf GetAsyncKeyState(vbKey9) ThenFor i = 1 To Text2.TextSendKeys "{9}"Next iEnd IfElseIf Text1.Text = "0" ThenIf GetAsyncKeyState(vbKey0) ThenFor i = 1 To Text2.TextSendKeys "{0}"Next iEnd IfElseIf Text1.Text = "ENTER" Or Text1.Text = "enter" Or Text1.Text = "Enter" ThenIf GetAsyncKeyState(vbKeyReturn) Then For i = 1 To Text2.TextSendKeys "{enter}"Next iEnd IfEnd IfEnd SubPrivate Sub Timer2_Timer()Static c As Integerc = c + 1Select Case cCase 1Label4.ForeColor = vbGreenCase 2Label4.ForeColor = vbYellowCase 3Label4.ForeColor = vbBlueCase 4Label4.ForeColor = &HFF00&c = 0End SelectEnd Sub。