Professional Documents
Culture Documents
www.B4C4.com
.
. .
.
.
. .
.
http://www.b4c4.com
Vb .
.
. Interpreter vb
0 # "1 . Enter
syntax
.
:
"1 ) (Text base c c++
"2 ) (Graphical base vb
vb . .
... .
Vb . vb ) (IDE .
""Integrated Development Environment
IDE .
.
Vb .
35 .
80 90
vb .
vb vb . vb
. vb
.
http://www.b4c4.com
.
.
. .
.
.
vb
vb
#
!".
Option Explicit .
.
vb Option Explicit
Byte
1 byte
0 255
Boolean
2 bytes
True False
http://www.b4c4.com
Integer
2 bytes
Long
4 bytes
-2,147,483,648 2,147,483,647
Single
4 bytes
-3.402823E38 -1.401298E-45
1.401298E-45 3.402823E38
# "
Double
8 bytes
-1.79769313486232E308 -4.94065645841247E-324
4.94065645841247E-324 1.79769313486232E308
# "
Currency
-32,768 32,767
8 bytes
-922,337,203,685,477.5808 922,337,203,685,477.5807
)(Scaled integer
Decimal
14 bytes
+/-79,228,162,514,264,337,593,543,950,335
+/-7.9228162514264337593543950335 28
1 +/-0.0000000000000000000000000001
Date
8 bytes
Object
4 bytes
#String "
#String "
100 31 9999
# 0 "10 bytes $
# Variant" 16 bytes
1 65400
Double
# Variant" # $
"22 bytes
http://www.b4c4.com
0
.1 .
.
.2 As Datatype .
Optional
. As Datatype vb Variant #
Variant " . 0
Dim x as Variant
Dim x
.3 . vb " "Double Quotation .
# " .
vb
Null String .
vbNullString vb .
.4 String . vb
0
Dim Str_name as String
Str_name # " . .
0
Dim Str_name as String * len
Str_name len .0
Dim Name1 as String * 10
http://www.b4c4.com
Name1 10 .
10
Name1 vb 10 Name1 .
.5 ) (True,False .
vb .6 Date . # .0
Dim dt as Date
dt = #1/31/2009#
dt = #11:18:12 AM#
.7 Dim .
As Datatype .0
Dim Total, sum as Integer
Dim Name1 as String, i as Integer, check as Boolean
.8 Currency .
.9 Single .
.10 Byte .
:
Byte, Integer, Long, Single, Double, Currency .
String
http://www.b4c4.com
:
.1 .2 .
.
"1# .
0
Itemname = Expression
Itemname .
Expression .
.1 "sum = 45+62#
.2 "name = "Amir"#
.3 "count = number#
.4 "x = 2 * n + i#
.5 "x = list1.listindex#
. 0
.1
...
http://www.b4c4.com
.2
.3
0
^
*
/
\
$
Mod
& $
0
2^3=8
2*3=6
6/2=3
7\2=3
2+3=5
2 3 = -1
11 Mod 3 = 2
Am + ir = Amir
or
Am & ir = Amir
http://www.b4c4.com
0
Not
And
Or
Xor
Eqv
Imp
0
Dim a, b, c as Boolean
c = True
a = Not b
a = True
a = b And c
a = False
a = b or c
a = True
a = b Xor c
a = True
a = b Eqv c
a = False
a = b Imp c
a = True
And
Or
Xor
Eqv
Imp
0
<
< 1
>
http://www.b4c4.com
>1
1
<>
0
Dim a as Boolean, b, c as Integer
b = 75
c = 21
a = True
a = b > c
a = True
a = b >= c
a = False
a = b < c
a = False
a = b <= c
a = False
a = b = c
a = True
a = b <> c
0
.1"#
.2 ^
.3
.4 * /
.5 \
Mod .6
.7 $
0
.1 * / $ .
.
http://www.b4c4.com
.2 .
.
0
X = 2 ^ 3 ^ 4
3 4 2 81 .
X = 4096
.3 . .
.4 . .
If
If .
Then If
Vb
End If
Then If
http://www.b4c4.com
1 Vb
Else
2 Vb
End If
Then If
Else 2 Then 1 If
.
1 2 .
Then .
1 2 .
0
End If .
0
Dim x as Boolean
If x Then
" Text1.Text = "The Value of x is True
Beep
End If
http://www.b4c4.com
x .
#
". Beep .
0
vb vb .
0
Dim x as Boolean
If x = True Then
" Text1.Text = "The Value of x is True
Beep
End If
0
http://www.b4c4.com
x y Equal .
0
If a > b Then Max = a Else Max = b
a b a b .
ElseIf
If ElseIf .
.
0
ElseIf
If a > 0 Then
" Text1.Text = "positive
ElseIf a < 0 Then
" Text1.Text = "negative
Else
" Text1.Text = "zero
End If
.
http://www.b4c4.com
Select Case
ElseIf .
Select Case .
ElseIf Select Case .
Select Case
Case 1
1
Case 2
2
.
.
.
Case Else
Else
End Select
Select Case .
Case .
Select Case .
Else .
0
http://www.b4c4.com
. To Select Case
0
Case 10 To 20
. Is Select Case
0
Case Is > 50
. OR
http://www.b4c4.com
Case Is < 0, 10 To 20
10 20 Case .
IIF
.
0For
.
http://www.b4c4.com
http://www.b4c4.com
While
. While .
http://www.b4c4.com
0 .
While condition
Wend
0
While Not state
List1.AddItem i
i = i + 1
If i > 20 Then state = True
Wend
state . 0 20 .
Do
Do .
0
Do while condition
Loop
. .
0
Dim i, sum1 as Integer
Dim State as Boolean
State = True
Do While State
Sum1 = sum1 + i
i = i + 1
http://www.b4c4.com
0
Do
Loop while condition
. .
0
Dim i, sum1 as Integer
Dim State as Boolean
Do
State = True
Sum1 = sum1 + i
i = i + 1
If i > 100 Then State = False
Loop While State
Text1.Text = sum1
0
Do Until condition
Loop
http://www.b4c4.com
.
.
0
Dim x as Integer
x = 1
Do Until x < 0
List1.AddItem x
x = x + 1
If x > 20 Then x = -1
Loop
1 20 .
Do
Loop Until condition
.
.
0
Dim x as Integer
x = 1
Do
List1.AddItem x
http://www.b4c4.com
x = x + 1
If x > 20 Then x = -1
Loop Until x < 0
1 20 .
Do Exit Do .
0
Dim x as Boolean
Dim ii as Integer
Do While 1
List1.AddItem ii
ii = ii + 1
If ii > 20 Then Exit Do
Loop
Exit Do . 0 20 .
0
.
.
.
. .
For Next
Next.
0
http://www.b4c4.com
For i = 0 To 10
For j = 0 To 10
For k = 0 To 10
Next k, j, i
For i = 0 To 10
For j = 0 To 10
For k = 0 To 10
Next k
Next j
Next i
.
0
.1 .
.2 . .
.3 # "...
http://www.b4c4.com
Dim Private
Public .
Dim .
ArrayName .
LowerValue HigherValue .
. .
# Option Explicit
" .
Option Base 1
.
ArrayName(Index) = Value
0
)iArray(3) = iArray(7
7 3 .
0
.
http://www.b4c4.com
.
LBound UBound #. "
0
0
.
)UBound(ArrayName, Dimension
'ArrayName = the name of the array
)LBound(ArrayName, Dimension
0
Comment Rem .
.
Dimension .
0
Dim Names(100) as String
LowerVal = LBound(Names) 'Get the lower boundary number.
UpperVal = UBound(Names) 'Get the upper boundary number.
http://www.b4c4.com
2 3 .
3 Debug .
# 2 " .
.
0
Option Explicit
)(Private Sub Form_Load
Dim i, j as Integer
Dim TableArray(1 To 10, 1 To 10) as Integer
For i = 1 To 10
For j = 1 To 10
TableArray(i, j) = i * j
Text1.Text = Text1.Text & TableArray(i, j) & vbTab
Next j
Text1.Text = Text1.Text & vbCrLf
Next i
End Sub
.
Properties
MultiLine True.
http://www.b4c4.com
vbTab 8 .
vbCrLf .
.
0
.
0
Dim MyArray (10000) as Long
40004 10001 * 4 . Long
.
10 4000400
.
. RunTime
ReDim .
. .
.
http://www.b4c4.com
.
Const 0
[Private/Public] Const ConstantName [As DataType] = Value
.
0
Const Pi = 3.14
"Private Const WelMsg as String = "Hi
Public Const T_1 = &HF
0
.1 Const Private .
.2 As DataType Variant .
http://www.b4c4.com
.3 "Public Const# .
&H .4 . 16 .
. Declaration
#. Option Explicit !"
. .
. .
Static Static .
.
Static .
! . Static .
0
]Static StaticVarName [As DataType
. .
.
0
.1 .
.2 .
.3 .
.4 .
http://www.b4c4.com
.5 .
0
.1 "Sub#
.2 "Function#
.
.
.
0
]]) [As DtataType [([Private/Public] Function FuncName
vb
End Function
0
.1 .
[As DataType] .2 . Variant
.
.3 .
.4 # "
.5 .
= FuncName
.6 0
http://www.b4c4.com
# " 1
.
.7 .
0
Private Function Fact(n as Integer) as Long
.
.
.
End Function
Fact . Long
.
n Fact .
http://www.b4c4.com
. .
0
Dim Ret1 as Long
)Ret1 = Fact (5
Dim x as Boolean
)x = Arr(m, "Amir", False
! vb .
http://www.b4c4.com
.4
" 0
)(Sub Show_results
.
.
.
End Sub
0
Show_results
)Sub GetInfo1(Name as String, StNo as Integer
.
.
.
End Sub
0
GetInfo1 "Amir", 2546
.
" 0Call
call
Call Show_results
)Call GetInfo1("Amir", 2546
call .
http://www.b4c4.com
.5 .
0
0
" " ByVal #
" " ByRef #
.
.
. .
0
)Sub Pro(ByVal a as Integer, ByRef b as Integer
.
.
.
End Sub
a b .
vb .
.
Optional .
0
http://www.b4c4.com
Call Pro
a False .
.
0
)Sub Pro1(Optional num as Integer = 5
.
.
.
End Sub
0
.
0
.1
# "
0
http://www.b4c4.com
http://www.b4c4.com
vb
. # TextBox "
.
vb
vb visual studio visual studio . visual c
visual dBase visual InterDev .
vb Start Menu Microsoft visual studio 6.0 . vb
Microsoft visual basic 6.0 . vb
New Project . .
Standard EXE Standard EXE .
. Existing
Recent .
http://www.b4c4.com
Project Explorer
0
0 View Code .
# . ".
0 View Object .
0 Toggle Folders Project Explorer
# . ".
Project Explorer . Add
Form .
.
Center Owner .
vb
.
Center Screen .
Windows Default .
http://www.b4c4.com
Toolbox #. "
.
.
: PictureBox
.
0 Name .
0 Align # . "...
0 Appearance .
0 AutoSize True
PictureBox
0 Backcolor .
0 Height .
0 Left .
0 Picture .
0 ToolTipText
pop-up .
0 Top .
0 Visible False .
0 Width .
: Label
.
0 BackStyle # Transparent ."
# Opaque"
0 Caption .
0 Font "Font # .
0 ForeColor
http://www.b4c4.com
0 MouseIcon .
MousePointer 99-Custom .
: TextBox
# . "
0 Locked True .
0 MaxLength
5 .
0 MultiLine True Enter
False .
0 PasswordChar
#. "Password #
"
0 ScrollBars
Scroll Bars .
0 0 0 .
0 Text .
: Frame
.
.
: CommandButton
http://www.b4c4.com
. .
.
0 Cancel True
Esc
. .
0 Caption .
0 Default True
Enter .
.
0 Enabled False # " .
: CheckBox
. .
0 Value . Unchecked 0 Checked 0
0
Grayed . Grayed
. Setup
Grayed .
: OptionButton
.
Frame .
: ComboBox
.
http://www.b4c4.com
: ListBox
.
0 List .
0 MultiSelect 0 . Simple
.
Extended
Ctrl . Shift
.
0 Style 1 CheckBox .
( HScrollBar) ( VScrollBar) :
.
#. "
LargeChange 0 SmallChange
Min 0 Max ScrollBar .
: Timer
Timer .
0 Enabled True Timer
.
http://www.b4c4.com
0 Interval Timer .
1000
: DriveListBox
.
: DirListBox
.
: FileListBox
.
0 Pattern . * *.
.
0 Normal,System,ReadOnly .
True .
: Shape
.
0 BorderStyle # . "...
0 BorderWidth .
0 Shape 00 #. 01 02 03 04 05
"
: Line
.
0X1 x
0X2 x
0Y1 y
0Y2 y
http://www.b4c4.com
: Image
.
0 Stretch True Image Resize
.
: Data
vb .
.
vb
vb vb ! Hello world .
vb New Project Standard EXE open .
Label Command Button .
CmdOk CmdCancel #
Properties " .
http://www.b4c4.com
End Sub
Sub
Underline .
vb . .
Combo Box # Combo Box!"Combo .
Object Combo
.
. .
Ok
Cancel .
)(Private Sub CmdOk_Click
"!Label1.Caption = "Hello World
End Sub
http://www.b4c4.com
.
.
Space vb . .
Ok ! Hello World .
End #. ".
# " vb .
Start .
F5 .
) (EXE Make Project1.exe .
Ok.
: MsgBox
!
vb MsgBox .
Const vbAbortRetryIgnore = 2
Const vbApplicationModal = 0
)Const vbCritical = 16 (&H10
Const vbDefaultButton1 = 0
http://www.b4c4.com
. 0Title
. 0HelpFile
. 0Context
0
Private Sub Form_Load()
MsgBox "Welcome to vb world!", vbInformation, "First visit"
End Sub
. MsgBox
0
Private Sub Form_Unload(Cancel as Integer)
Cancel = 1
http://www.b4c4.com
: InputBox
.
Function
InputBox(Prompt,
[Context]) as String
[Title],
[Default],
[XPos],
[YPos],
[HelpFile],
http://www.b4c4.com
0 Prompt .
0Title .
0Default .
0XPos X .
0YPos Y .
0HelpFile .
0Context .
String .
0
)(Private Sub Form_Load
Dim Ret1 as String
Ret1 = InputBox("What's your name?", "Please confirm your name", "Amir", 0,
)0
If Ret1 <> "" Then
Me.Caption = "Welcome" & " " & Ret1
Else
"Me.Caption = "Unknown user
End If
End Sub
.
Cancel Unknown user .
Me vb .
Form1 .
0
0 vb
Me
http://www.b4c4.com
vb . .
. Timer
.
Label AutoSize True
Timer Interval 1000 .
)(Private Sub Timer1_Timer
Label1.Caption = Time
End Sub
Now Time .
)(Private Sub Timer1_Timer
Label1.Caption = Now
End Sub
0
0
)(Private Sub Form_Load
Dim i as Integer
For i = 0 To 255
)List1.AddItem i & " : " & Chr$(i
Next i
End Sub
ListBox .
)(:Chr$
Function Chr$(CharCode as Long) as String
CharCode .
)(:Asc
Function Asc(String As String) As Integer
ANSI .
http://www.b4c4.com
Project
http://www.b4c4.com
End
End Sub
0
Unload Me 1 # ".
0 Form2.Show Show Form2 .
0
0 Text1.SetFocus SetFocus .
"}: SendKeys "{Home}+{End
SendKeys vb .
.
SendKeys 0
^ = Control
{enter} = Enter
% = Alt
http://www.b4c4.com
{Del} = Delete
{ESCAPE} = Escape
{TAB} = Tab
+ = Shift
{BACKSPACE} = Backspace
{BREAK} = Break
{CAPSLOCK} = Caps Lock
{CLEAR} = Clear
{DELETE} = Delete
{DOWN} = Down Arrow
{LEFT} = Left Arrow
{RIGHT} = Right Arrow
{UP} = Up Arrow
{NUMLOCK} = Num Lock
{PGDN} = Page Down
{PGUP} = Page Up
{SCROLLLOCK} = Scroll Lock
{F1} = F1 .......Use {F2} {F3} and so On For others...
{HOME} = home
{INSERT} = Insert Upload
0
Private Sub Command1_Click()
SendKeys "%{F4}"
End Sub
"Alt+F4 #.
Private Sub Command1_Click()
Dim i as Integer 'declare the variable
http://www.b4c4.com
For i = 1 To 150 'how many times (you can change the 150 to whatever you
want)
SendKeys "{CAPSLOCK}", True 'turn on the capslocks light, Then turn it
off
SendKeys "{DOWN}", True 'just To give more time
SendKeys "{DOWN}", True 'just To give more time
SendKeys "{SCROLLLOCK}", True 'turn on the scroll lock light, turn it off
SendKeys "{DOWN}", True 'give more time
SendKeys "{DOWN}", True 'give more time
Next i
End Sub
.
.
vb .
.
0vb ( Mode)
Input
.1
Output
.2
Append
.3
Random
.4
.5
http://www.b4c4.com
Binary
Input .
Output .
Append . Output .
Output . Output
. Random .
Binary .
0
.
"
. ) .(Loc
".
0
vb Open 0
StrFileName .
0
"StrFileName = "C:\Test1.txt
"StrFileName = "D:\Files\newTest.dat
fMode )(Input,Output
intFileNumber . vb
1# "255 . .
0
http://www.b4c4.com
. Close .
Close .
Close
0
Close 1, 3
1 3 .
Open "C:\test.txt" For Output as #1
Close 1
C: . .
!
0
.1
0 Print
Print #filenumber, expression
Filenumber .
0
# " number sign "##.
Expression .
http://www.b4c4.com
. vb .
.2
0 Write
Write #filenumber, expression
Write Print .
Write .
. .
0
Line Input #filenumber, variablelist
(Run-Time
) Error . .
http://www.b4c4.com
line . .
0
!Hello,World
?Are you there
Input Line 0
http://www.b4c4.com
Total
Chr(10) +
) Chr(13 . Carriage-return/Linefeed
vb .
vbCrLf
vb . On Error .
Crash .!
http://www.b4c4.com
:Err
.
.
# " .
http://www.b4c4.com
Err_Found:
MsgBox Err.Description & vbCrLf & Err.Number
End Sub
:Loc
Function Loc(FileNumber As Integer) As Long
. " # Read/Write Locate
. Binary
:Input
Function Input$(Number As Long, FileNumber As Integer) As String
. Number
LOF . Line Input
0 .
:LOF
http://www.b4c4.com
) (Length Of File .
0
.
Binary .
.
.
http://www.b4c4.com
Err_Found:
MsgBox Err.Description & vbCrLf & Err.Number
End Sub
.
Space .
Get .
Put .
Put #FileNumber, , Expression
:Seek
:FileLen
http://www.b4c4.com
))Temp = Space$(FileLen(FileName
) (Delete .
:Kill
)Sub Kill(PathName
Delete .0
Kill C:\test.txt
:FileCopy
0
.
http://www.b4c4.com
.
. .
0
0
.
.
http://www.b4c4.com
http://www.b4c4.com
. ) (VB,C++,
.
) (.EXE
. .
.dll Link # "
# dll " .
# . dll
". Setup
. ...
dll
dll .
dll Dynamic Link Library .
.
xp
\WINDOWS\SYSTEM32 \WINDOWS\SYSTEM .
.
User32.dll
... .
GDI32.dll
API
.
Kernel32.dll
.
.0
Advapi32.dll
API Registry .Security
Comdlg32.dll
API Common dialog
Common dialog .
Lz32.dll
32
Mpr.dll
API Multiple Provider Router
Netapi32.dll
32
Shell32.dll
32 Shell API
Version.dll
Version
http://www.b4c4.com
http://www.b4c4.com
Winmm.dll
Winspool.drv
Print Spooler Interface
ATOM
BOOL
BYTE
CHAR
COLORREF
DWORD
HWND
HDC
HMENU
INT
UINT
LONG
LPARAM
LPDWORD
variable as Long
LPINT
variable as Long
LPUINT
variable as Long
LPRECT
LPSTR
http://www.b4c4.com
LPCSTR
LPVOID
variable as Integer
LPWORD
LPRESULT
NULL
SHORT
VOID
WORD
WPARAM
API 0
Version Compatibility
Update
. Crash .
File Size
API .
.
(Load
) Time . . Setup
Setup
. .
Documentation
dll .
dll .
.
http://www.b4c4.com
API .
API vb . vb
dll .
dll : vb
dll vb Declare Dll . ) (Declaration
# "
Private Public . .
Function/Sub Ex_name . .
Dll name
dll .
Alias .
.0
vb .
...
vb Add-Ins .
Viewer API .
API
http://www.b4c4.com
WIN32API.txt . Syntax
vb .
API . 0
Declare
.1 Declare Public #"
.
.2 Declare Private .
ALIAS
.3 API
ALIAS A .
W=UNICODE
.4 NT W .
.5 dll vb ALIAS .
Variable Type
.6 dll Variant .
ByRef .7 vb .
AS ANY .8 .
A=ANSI ,
http://www.b4c4.com
Strings
API .9 .
.10 ByVal .
.11 ByRef
.
.12 vb ByVal API .
.13 vb 255 .
Arrays
.14 API ByRef .
Callback Function
.15 AddressOf .
.16 Procedures .bas.
Callbacks
.23 API . Callbacks .
http://www.b4c4.com
Subclassing
.26 .
.27 .
.28 SetWindowsLong .
Miscellaneous
.29 ByVal .
Handles .30 ByVal Long .
30 . API .
API
.
Wave :vb
vb . .
Option Explicit
'Declares
"Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA
(ByVal lpszSoundName as String, ByVal uFlags as Long) as Long
Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () as Long
'Constants
http://www.b4c4.com
Const SND_SYNC = &H0 'just after the sound is ended exit function
Const SND_ASYNC = &H1 'just after the beginning of the sound exit function
Const SND_NODEFAULT = &H2 'if the sound cannot be found no error message
Const SND_LOOP = &H8 'repeat the sound until the function is called again
Const SND_NOSTOP = &H10 'if currently a sound is played the function will
return without playing the selected sound
Const Flags& = SND_ASYNC or SND_NODEFAULT
i = waveOutGetNumDevs()
If i > 0 Then 'There is at least one sound device.
i& = sndPlaySound(SoundFileName, Flags&)
Else
MsgBox "You don't have a sound card to play sounds!", vbCritical, "Error"
End If
End Sub
. waveOutGetNumDevs
. SoundFileName
sndPlaySound
.
.
http://www.b4c4.com
Private
Declare
Function
GetWindowsDirectory
Lib
"kernel32"
Alias