Friday, September 22, 2017
ສຳລັບບົດນີ້ ເປັນການສ້າງໂປຣແກຣມ ໃຫ້ເປີດເອງຕອນເວລາເປີດຄອມ
ມີໂຄ້ດດັ່ງນີ້
ແບບທີ່ 1
Dim Startup_key As String
Startup_key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
Dim Reg As Object
Set Reg = CreateObject("wscript.shell")
Reg.RegWrite Startup_key & App.EXEName, App.Path & "" & App.EXEName & ".exe"
ສຳລັບ
- App.EXEName ແມ່ນມີຄ່າເທົ່າຊື່ຂອງໂປຣແກຣມເຮົາເອງ
- App.Path ແມ່ນ ເສັ້ນທາງທີ່ໂປຣແກຣມເຮົາເປີດຢູ່
ແບບທີ່ 2
[Read more…]
ໃນບົດນີ້ ແມ່ນການຂຽນໂປຣແກຣມໃຫ້ດາວໂຫຼດໄຟລ ຈາກອິນເຕີເນັດ
ຕົວຢ່າງ 1
ເປັນ Function ສຳລັບດາວໂຫຼດໄຟລ
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean
//'Download the file. BINDF_GETNEWESTVERSION forces
//'the API to download from the specified source.
//'Passing 0& as dwReserved causes the locally-cached
//'copy to be downloaded, if available. If the API
//'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, _
sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function
ຕົວຢ່າງ 2
[Read more…]
ການໃຊ້ Timer ໃນ Visual Basic 6 ເພື່ອສະແດງເຖິງການກຳນົດເວລາໃນໂປຣແກຣມ
ມີຕົວຢ່າງດັ່ງນີ້
ເພີ່ມ Timer Control ໃນຟອມ
ໂຄ້ດ:
Option Explicit
' Add a Timer control to your project. It will be Timer1
' It looks like a stop watch in the IDE.
Dim OldTime As Date
Dim newTime As Date
Dim diff As Date
Private Sub Form_Load()
OldTime = Time
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static x As Long
Static zz$, ss$
x = x + 1
newTime = Time
diff = DateDiff("s", OldTime, newTime)
Form1.Caption = (diff 3600) & ":" & Format((diff 60 Mod 60), "00") & ":" & _
Format((diff - ((diff 60) * 60)), "00")
' Debug.Print (diff 3600) & ":" & Format((diff 60 Mod 60), "00") & ":" & _
Format((diff - ((diff 60) * 60)), "00")
If newTime = DateAdd("s", 360, OldTime) Then ' Add 360 seconds
Timer1.Enabled = False
' You time is UP! Do something!
Beep
End If
End Sub
[Read more…]
ເປັນໂປຣແກຣມ ກວດຈັບ ຫາ ຊ່ອງ USB ເມື່ອ ເຮົາສຽບ USB ເຂົ້າໃສ່ຄອມ
Image does not exist: https://www.planet-source-code.com/Upload_PSC/ScreenShots/PIC200721912582850.GIF
ມີໂຄ້ດ ດັ່ງນີ້:
ສຳລັບໄຟລໂມດູນ
Module1.bas ແມ່ນປະກາດ API Function ໄວ້
Option Explicit
Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
[Read more…]
Thursday, September 21, 2017
ສຳລົບບົດນີ້ແມ່ນຮຽນກັບກັບ ການຈັດການກັບໄຟລ ແລະ ໂຟນເດີ ໃນພາສາໂປຣແກຣມ Visual Basic 6
1. ການສຳເນົາໄຟລ
ໂຄ້ດ:
FileCopy(SourceFile, DestinationFile)
- SourceFile ແມ່ນໄຟລຕົ້ນທາງ
- DestinationFile ແມ່ນໄຟລປາຍທາງ
2. ການຍ້າຍໄຟລ
ໂຄ້ດ:
Name "c:/test1.txt" as "d:/temp/blabla.txt"
3. ການລົບໄຟລ
ໂຄ້ດ:
Kill "ຊື່ໄຟລ"
4. ການສ້າງໂຟນເດີ
ໂຄ້ດ:
Mkdir "ຊື່ໂຟນເດີ"
5. ການລົບໂຟນເດີ
ໂຄ້ດ:
RmDir "ຊື່ໂຟນເດີ"
ແລະ
6. ການສັ່ງເປີດໄຟລ ໂປຣແກຣມ
ໂຄ້ດ:
Shell(pathname[,windowstyle])
ຕົວຢ່າງ:
' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.
Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator.
Wednesday, September 20, 2017
ບົດນີ້ ເປັນການຂຽນໂປຣແກຣມ ການຄວບຄຸມ Keyboard ໃນ Visual Basic 6
1. ຕາຕະລາງ ຄ່າຂອງ Ascii
ASCII
|
Chr
|
ASCII
|
Chr
|
ASCII
|
Chr
|
8 |
Backspace |
61 |
= |
98 |
b |
13 |
Carriage Return or Enter key |
62 |
> |
99 |
c |
32 |
Space |
63 |
? |
100 |
d |
33 |
! |
64 |
@ |
101 |
e |
34 |
“ |
65 |
A |
102 |
f |
35 |
# |
66 |
B |
103 |
g |
36 |
$ |
67 |
C |
104 |
h |
37 |
% |
68 |
D |
105 |
i |
38 |
& |
69 |
E |
106 |
j |
39 |
‘ |
70 |
F |
107 |
k |
40 |
( |
71 |
G |
108 |
l |
41 |
) |
72 |
H |
109 |
m |
42 |
* |
73 |
I |
110 |
n |
43 |
+ |
74 |
J |
111 |
o |
44 |
, |
75 |
K |
112 |
p |
45 |
- |
76 |
L |
113 |
q |
46 |
. |
77 |
M |
114 |
r |
47 |
/ |
78 |
N |
115 |
s |
48 |
0 |
79 |
O |
116 |
t |
49 |
1 |
80 |
P |
117 |
u |
50 |
2 |
81 |
Q |
118 |
v |
51 |
3 |
82 |
R |
119 |
w |
52 |
4 |
83 |
S |
120 |
x |
53 |
5 |
84 |
T |
121 |
y |
54 |
6 |
85 |
U |
122 |
z |
55 |
7 |
86 |
V |
123 |
{ |
56 |
8 |
87 |
W |
124 |
| |
57 |
9 |
88 |
X |
125 |
} |
58 |
: |
89 |
Y |
126 |
~ |
59 |
; |
90 |
Z |
127 |
DEL |
60 |
< |
97 |
a |
|
|
[Read more…]
ໃນບົດຮຽນນີ້ ເຮົາຈະຮຽນກ່ຽວກັບ ການສ້າງໄຟລ ແລະ ບັນທຶກໄຟລ ລົງໄປໃນ ຮາດດິດ ແລ້ວ ອ່ານໄຟລ ໃນໂປຣແກຣມ ທີ່ສ້າງຈາກ Visual Basic 6
1. ການສ້າງໄຟລ
ໂຄ້ດ:
Open "fileName" For Output As #fileNumber
ຕົວຢ່າງ
Open "c:\My Documents\sample.txt" For Output As #1
ຕົວຢ່າງ ການສ້າງໄຟລ
Private Sub create_Click()
Dim intMsg As String
Dim StudentName As String
Open "c:\My Documents\sample.txt" For Output As #1
intMsg = MsgBox("File sample.txt opened")
StudentName = InputBox("Enter the student Name")
Print #1, StudentName
intMsg = MsgBox("Writing a" & StudentName & "to sample.txt")
Close #1
intMsg = MsgBox("File sample.txt closed")
End Sub
[Read more…]