VBÃüÃû¹æÔò¼°´úÂë¹æ·¶
VBA
ÃüÃû¹æÔò¼°´úÂë¹æ·¶
Âíά·å
(maweifeng@263.net
)
1.
VBA
ÃüÃû¹æÔò
Ò»¸öºÃµÄÃüÃû¹æÔò¿ÉÒÔÌá¸ß³ÌÐòµÄ¿É¶ÁÐÔ£¬¼õÉÙ´íÎó·¢ÉúµÄ¸ÅÂÊ£¬ÃüÃû¹æÔò²»ÊÇÒ»¶¨µÄ£¬²»Í¬µÄÈËÓв»Í¬µÄ¹æÔòºÍÏ°¹ß£¬µ«ÔÚ±à³Ì¹ý³ÌÖУ¬¶ÔÓÚ¸öÈË»ò¹¤×÷×飬һ¶¨Òª×ñÊØÏàͬµÄÃüÃû¹æÔò¡£
1.1.
±äÁ¿¡¢³£Á¿¡¢×Ô¶¨ÒåÀàÐͺÍö¾Ù
±í
1
‑1
¸ÅÀ¨Á˱äÁ¿¡¢³£Á¿µÄ»ù±¾ÃüÃû¹æÔò¡£
±í
1
‑
1
±äÁ¿¡¢³£Á¿ºÍö¾ÙÀàÐ͵ÄÃüÃû¹æÔò
ÔªËØ
ÃüÃû¹æÔò
±äÁ¿
<
·¶Î§
><
Êý×é
><
Êý¾ÝÀàÐÍ
>
ÃèÊö£¨Ê××Öĸ´óд£©
³£Á¿
<
·¶Î§
><
Êý¾ÝÀàÐÍ
>
ÃèÊö£¨È«²¿´óд£©
Óû§×Ô¶¨ÒåÀàÐÍ
Type
ÃèÊöÃû³Æ
<
Êý¾ÝÀàÐÍ
>
ÃèÊö
End Type
ö¾ÙÀàÐÍ
Enum <
¹¤³Ìǰ׺
>
Ò»°ãÃèÊö
<
¹¤³Ìǰ׺
><
Ò»°ãÃèÊö
><
¾ßÌåÃû³Æ
1>
<
¹¤³Ìǰ׺
><
Ò»°ãÃèÊö
><
¾ßÌåÃû³Æ
2>
End Enum
<
·¶Î§
>
±íʾÁ˱äÁ¿µÄ×÷ÓÃÓò£¬¶ÔÓÚ
Private
ÀàÐͺÍÄ£¿é¼¶±äÁ¿£¬Ò»°ãʹÓÓ
m
”ǰ׺±íʾ£¬¶ÔÓÚ
Public
ÀàÐ͵ıäÁ¿£¬Ò»°ãʹÓÓ
g
”ǰ׺±íʾ£¬¶ø¶ÔÓÚ¹ý³ÌÄڵľֲ¿±äÁ¿£¬Ôò²»Ê¹ÓÃǰ׺¡£Èç¹ûÊÇÊý×飬ÔÚ·¶Î§Ç°×ººóÔö¼Ó“
a
”±íʾ±äÁ¿ÎªÊý×é¡£
¶ÔÓÚÊý¾ÝÀàÐÍ£¬Ò»°ãʹÓÃ
±í
1
‑2
µÄǰ׺±íʾ¡£
±í
1
‑
2
ÃüÃû¹æÔò³£ÓÃǰ׺
ǰ׺
Êý¾ÝÀàÐÍ
ǰ׺
Êý¾ÝÀàÐÍ
ǰ׺
Êý¾ÝÀàÐÍ
is
Boolean
cm
ADODB.Command
cmb
MSForms.ComboBox
byt
Byte
cn
ADODB.Connection
chk
MSForms.CheckBox
cur
Currency
rs
ADODB.Recordset
cmd
MSForms.CommandButton
dte
Date
fra
MSForms.Frame
dec
Decimal
cht
Excel.Chart
lbl
MSForms.Label
f
Double
£¬
Single
rng
Excel.Range
lst
MSForms.ListBox
i
Integer
£¬
Long
wb
Excel.Workbook
mpg
MSForms.MultiPage
obj
Object
ws
Excel.Worksheet
opt
MSForms.OptionButton
str
String
spn
MSForms.SpinButton
u
User-defined type
cbr
Office.CommandBar
txt
MSForms.TextBox
v
Variant
ctl
Ïà¹ØÎĵµ£º
vb class Property Get¡¢Property Let ʹÓÃ
<%
'ÔÚ Class ¿éÖУ¬³ÉԱͨ¹ýÏàÓ¦µÄÉùÃ÷Óï¾ä±»ÉùÃ÷Ϊ Private(˽ÓгÉÔ±£¬Ö»ÄÜÔÚÀàÄÚ²¿µ÷ÓÃ) »ò Public(¹«ÓгÉÔ±£¬¿ÉÒÔÔÚÀàÄÚÍⲿµ÷ÓÃ) ¡£
'±»ÉùÃ÷Ϊ Private µÄ½«Ö»ÔÚ Class ¿éÄÚÊǿɼûµÄ¡£±»ÉùÃ÷Ϊ Public ²»½öÔÚ Class ¿éµÄÄÚ²¿ÊǿɼûµÄ£¬¶Ô Class ¿éÖ®ÍâµÄ´úÂëÒ²Êǿɼûµ ......
“×Ô¶¯µã»÷°´Å¥”С¹¤¾ßVBÔ´Âë
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Pri ......
'* ************************************************************** *
'* ³ÌÐòÃû³Æ£ºButton.ctl
'* ³ÌÐò¹¦ÄÜ£ºÍ¸Ã÷¸¡¶¯°´Å¤
'* ×÷Õߣºlyserver£¬×îºóÐÞ¸ÄÈÕÆÚ£º2009Äê11ÔÂ
'* ÁªÏµ·½Ê½£ºhttp://blog.csdn.net/lyserver
'* ************************************************************ ......
ÌâÄ¿£ºÒ»¼ÒСÐͺ½¿Õ¹«Ë¾¸Õ¸Õ¹ºÂòÁËһ̨¼ÆËã»ú£¬ÒÔʹÓÃеĻúƱ×Ô¶¯Ô¤¶©ÏµÍ³£¬Õâ¼Ò¹«Ë¾ÒªÇóÎÒÃÇ¿ª·¢Õâ¸öÐÂϵͳ¡£ÎÒÃÇÐèÒª±àдһ¸öÓ¦ÓóÌÐò£¬¶ÔÕâ¼Òº½¿Õ¹«Ë¾Î¨Ò»µÄÒ»¼Ü·É»ú£¨ÈÝÁ¿Îª10¸ö×ù룩µÄÿ¸öº½°à·ÖÅä×ùλ¡£Õâ¸öÓ¦ÓóÌÐòÓ¦¸ÃÊäÈëÏÂÃæÕâЩѡÏÇëÊäÈë1Ñ¡ÔñÍ·µÈ²ÕºÍÇëÊäÈë2Ñ¡Ôñ¾¼Ã²Õ¡£Èç¹ûÓû§ÊäÈë1£¬Ó¦ÓóÌÐòÓ¦¸Ã·ÖÅäÒ ......
±¨¸æÊé
Ãû³Æ
ʵÑé10-1 ʵÏÖ¼ÆËãÆ÷µÄ¹¦ÄÜ
ÐÕÃû
Ö¸µ¼½Ìʦ
ѧºÅ
ÈÕÆÚ
ÈÎÎñÇåµ¥
ÔÚ±¾Á·Ï°ÖУ¬Ä㽫ʹ»æÖƵļÆËãÆ÷Íê³É¼òµ¥µÄËÄÔòÔËËã¡£
1) Æô¶¯Visual Studio 2005¡£
2) н¨Ò»¸öVB WindowsÓ ......