การเขียนโปรแกรม VB6.0 ทำไว้กันลืม
ในการเขียนโปรแกรมด้วย Microsoft Visual Basic ยังมีหลายๆลูกเล่น ที่จะทำให้โปรแกรมน่าสนใจ บางคำสั่งก็ไม่ค่อยได้ใช้งาน มีลืมๆไปบ้าง เรามาดูรายละเอียดกัน
1. การเขียนโปรแกรมเรียกไฟล์ Exe ให้แสดงแบบ Top
‘—————————————————–
‘—————————————————–
2. การเขียนโปรแกรม Open และ Save Txt
เรียก Components> Microsoft Common Dialog Control 6.0
‘——————————————————
Private Sub Command1_Click()
‘เปิดไฟล์
Dim ContentFile As String
On Error GoTo A
Form1.CommonDialog1.ShowOpen
Open Form1.CommonDialog1.FileName For Input As #1
Do Until EOF(1)
Input #1, ContentFile
Form1.Text1 = Form1.Text1 + ContentFile + vbCrLf
Loop
Close #1
A:
End Sub
‘———————————————————
Private Sub Command2_Click()
Dim filelocation As String
‘ Save ไฟล์
CommonDialog1.Filter = “Text File (*.txt)|*.txt|All File (*.*)|*.*”
CommonDialog1.FileName = “”
CommonDialog1.ShowSave
filelocation = CommonDialog1.FileName
‘เลือกสถานที่่ที่จะ Save
Open filelocation For Append As #1
Print #1, Text1.Text
Close #1
End Sub
‘——————————————————
0 Comments