��Ѻ��úѭ (Back to Content)
��������� (Program Language) # ��� �Ըա���ҵðҹ㹡�������������Ѻ�ʴ��������ѧ���������� �����������˹����ҡó���С�õդ������¨ҡ�������������������¹��� ����������������������������ö�к����ҧ�Ѵਹ�֧�����ŷ�����������зӧҹ ����Ըա�÷�����������л����żŢ���������ҹ�� ������Ԥ (Basic Language) ��� ���Ҥ�����������Ѳ���¨��� ������ (John Kemeny) ��� ����� ��õ�� (Thomas Kurtz) ����Է����´�������� (Dartmouth College) 㹻դ.�. 1963 �Ԫ����ԡ (Visual Basic) ��� ���Ҥ�������������Ѻ���ҧ���������ء�� (Application) �����ҹ�����ҧ��ҡ���º��к���Ժѵԡ���Թ��� �������ö���¡���ѵ�ط����������������������ԡ�� Programming :: VB :: VB.NET :: ASP.NET :: GWBasic :: ASP :: |
���� 1 :�� general component ����к��������������á |
Download : chap001.zip |
unload me ? ���ҧ����� ������������Դ������ա����˹�� ? ���ҧ command button ������������� msgbox("x") ? ���ҧ command button ������������� x = InputBox("abc", "def") |
Download : chap002.zip |
Text1 = Text1 + 1 ? ���ҧ�����ٳ�ͧ ? ���ҧ�����ǡ�ͧ ? ���ҧ text box �ա 1 ��з�����úǡ ź �� text box ������������ |
Download : chap003.zip |
Shape1.Shape = 1 Shape1.Shape = 2 ? ������� frame ���������͡��˹� backcolor ���� bordercolor ���� fillcolor ? ���������ͧ ����Ѻ��˹���Ҵ width ��� height �ͧ shape |
Download : chap004.zip |
Label1.FontSize = 10 ? ���� label �������¹��Ҵ�� 2 label ������ѹ ? ����������͡ ������ msgbox |
Download : chap005.zip |
Unload Me Unload Form2 Form1.Show ? ���ҧ�������� 4 ��� ���ջ�������Դ�Դ�������� ? ���ҧ�������� 5 ����դ���� msgbox ��Шӻ��� |
Download : chap006.zip |
Frame1.Visible = False Frame1.Visible = True ? ���ҧ frame ���� ��л��������繻������� ? ���ҧ frame ���� �������ջ�������� frame ��� |
Download : chap007.zip |
Randomize (Timer) For i = 1 To 20 List1.AddItem Int(Rnd * 100) Next List1.Clear List1.RemoveItem (Text2) Text1 = List1 ? ����Ẻ�����ӹ������� ? ��������Ţ�ҡ���� 20 �ӹǹ ����դ���ҡ���� 2 ��ѡ |
Download : chap008.zip |
List1.SetFocus List1.ListIndex = 5 Combo1.AddItem List1 ? ���ҧ combo box ���Ѻ����ա���˹�� ���ѹ�Ѻ�ͧ��� ? �Ҽ�����ͧ�ء���� combo box �ʴ�������ӹǹ |
Download : chap009.zip |
y = Split(List1, ",", -1, vbTextCompare) z = Int(y(0)) + Int(y(1)) Combo1.AddItem z Combo1.Text = z List1.RemoveItem List1.ListIndex Text2 = "Even" If z Mod 2 = 1 Then Text2 = "Odd" Text1 = Combo1.ListCount List1.SetFocus List1.ListIndex = z ? ����Ҽ���� 2 ������������ �������¹�繼Ťٳ ? ����� 2 ��� ����к�÷Ѵ ��������� 3 |
Download : chap010.zip |
? �������ࢵ������ ? �������¹�������� |
Download : chap011.zip |
List1.ListIndex = -1 For i = 1 To List1.ListCount List1.ListIndex = List1.ListIndex + 1 If InStr(1, List1, Text1, vbTextCompare) > 0 Then List2.AddItem List1 End If Next ? ����ࢵ������ ? ������� ź ��� ��ҡѺ�������� |
Download : chap012.zip |
For i = 1 To List1.ListCount List1.ListIndex = List1.ListIndex + 1 y = Split(List1, ",", -1, vbTextCompare) If y(0) = Val(Text2) Then Text3 = y(1) Text4 = y(2) End If Next List1.ListIndex = -1 ? ����ࢵ������ ? ������ա�ä������� 3 Ẻ ? ������� ���� ź ��� |
Download : chap013.zip |
form2.visible = true ' form2.show ' end ' unload form1 ? ��Ẻ������ ������¹�Ҿ ? �� game �Ѻ�Դ�Ҿ���� ��Ҷ١�֧�Դ form ���� |
����������� �����繵�ͧ Download | ������ʴ����ԡ� �Թ���ǵ����ͧ��� ����ö��任���ء��Ѻ�������ҧ � �� ���� Timer component ���¨Ѵ��ô�ҹ���� ��觷���ͧ�� ��ͻ�Ѻ properties �ͧ timer ���ǹ�ͧ interval ����� 1000 ��� 1 �Թҷ�
Private Sub Timer1_Timer() Text1 = Format(Time, "long time") End Sub ? ��Ẻ������ ��Ѻ�ٻẺ�����§�� ? ���������ҧ � ��й�任���ء�������ҹ�����ͧ��� |
Download : photoword.zip | photoword.exe | �繡�äǺ��� object ��ҧ � ����Դ�Դ�س���ѵ� �����ͧ��� �繡����¹������ ���ҡ㹡���ҧἹ ��С�����Ҿ �س���ѵԷ������Ǣ�ͧ�� enabled visible transparent width height backstyle caption windowstate
? ��Ẻ������ ��Ѻ�ٻ�Ҿ���Ҿ��� ? ��价�����ҹ���ҡ��� ? ��任���ء������Ѻ�Դ�Ҿ |
Download : ballrun.exe | �������Ǩ�ͺ���˹觢ͧ�ѵ�ط�����㹨��Ҿ ����� width �Ѻ height �����ҡ ���ͤ�����ͧ������֡�� ��͡�����¹����äǺ����ѵ�� �������¹�ŧ���˹� ������ªԹ�Ѻ��äǺ��� width height left top ��С���ʴ���
? ��Ẻ������ ��Ѻ��Ҵ�ٻ ��������¹�� image ? ���� object 㹡����� ? ������ء�� ������¹�Ҿ ��������� ��� object ���ٴբ�� |
Download : dif.zip | dif.exe ������ҧ���������ǡѺ���� �����ʹ� Text1 = Time - CDate(Form2.Text1) Text1 = Format(Text1, "long time") | ���������ʴ���äǺ����ѵ�� �Ӻ���� 15 �һ�Ѻ��ا ����������������������¿���� �ա���觤�������ҧ����� ��������� end ��ش����� ��觷���ҡ㹡����¹���������� ������Ҿ�����ʹ� �����ҧ�繵�����͡ ��ǹ��������鹡�äǺ����ѵ�� ��С���觤�������ҧ���������ѡ
? ��Ẻ������ ����¹ image ��л�Ѻ���ٴ��ҡ��� ? ���� level �����������������ҡ��� ᷹��������§ 3 ? ������ء�� ���͡Ẻ����ҧ � �������ͧ |
Download : numtxt.exe |
? ��Ẻ������ ����¹�ٻẺ ��������س���ѵ� on change ���� command_click ᷹ ? �ͧ����������Ѻ object ��ҧ � �����ջ���ª���� ? ������ء�� �����ҧ�ó��֡�һ�Сͺ����� function ��� |
Download : slide.exe |
? ��Ẻ������ �������ӹǹ slide ����¹�Ҿ �������¹�����ŴٹФ�Ѻ ? �ͧ���������� slide �����ͧ�� ? �ͧ���� slide � 1 form ������Ѻ ���������仴��� ����բ����������ٻẺ |
? ��Ẻ������ �ջ��� + �������� ? ��������ź �ٳ ��� ? ���������ŧ�Ţ�ҹ |
�Ҩҡ������ҧ 18 ����¹�ӹǹ�Թ�繵���ѡ�� ���������§��ҹ����ѡ������
? ��Ẻ������ �ջ��� + �������� ? ����¹�繹Ѻ�Ţ���� Bank |
���� 2 :�к��ҹ���������� Data Control |
Download : chap101.zip |
1. �Դ VB6.0 �������͡ Standard EXE ���� Open 2. click Textbox �ҡ Toolbox 3. ���� mouse 价�� form ���� click ��ҧ��� ������ҡ价ҧ��Ң�Ҵ������������ 4. �ӵ����� 3 ���ҧ text2 ��� text3 ���������ʴ������� 5. click Data ���� Data control �ҡ Toolbox ���ǷӤ���¢�� 3 6. ��ػ���� form1 ���� Object ���� 4 Object �Ф�Ѻ 7. ��˹��س���ѵ� ���� Properties ���Ѻ Data1 3 ���ҧ�ѧ�����Ŵ�ҹ��ҧ 8. ��˹��س���ѵ� ���� Properties ���Ѻ Text1 2 ���ҧ�ѧ�����Ŵ�ҹ��ҧ 9. ��˹��س���ѵ� ���� Properties ���Ѻ Text2 2 ���ҧ�ѧ�����Ŵ�ҹ��ҧ 10. ��˹��س���ѵ� ���� Properties ���Ѻ Text3 2 ���ҧ�ѧ�����Ŵ�ҹ��ҧ 11. ���ǡ� save Project ����ͧ�����������¹ .. �������¡���ա�������� 12. �š�èѴ�纨��� 2 ���Ǥ�� .vbp ��� .frm ��� save ���ǡ��ͧ�Դ VB 13. �ͧ�Դ VB ����Դ��� .vbp ���������٤�Ѻ 14. ����ջѭ�ҡ�÷ӵ�� ���仴ٺ���� 107 ����������������� �������ҧ��������Ѻ
Data1 Properties Databasename = C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb RecordType = Table RecordSource = Categories Text1 Properties Datasource = Data1 Datafield = CategoryID Text2 Properties Datasource = Data1 Datafield = CategoryName Text3 Properties Datasource = Data1 Datafield = Description ? �������¹�� table ��� �� Customers ���� Employees �繵� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
Download : chap102.zip |
��ǹ�ͧ Data control ��˹����� 101 DBGrid1 Properties DataSource = Data1 ? �������¹�� table ��� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
Download : chap103.zip |
��ǹ�ͧ Data control ��˹����� 101 ����觤�÷�Һ Data1.Recordset.AddNew If Len(Trim((Text2)) > 0 Then Data1.Recordset.UpdateElse Data1.Recordset.CancelUpdate Msgbox "����ա�û�Ѻ��ا���" End If ? �������¹�� table ��� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
Download : chap104.zip |
- Data1.Recordset.Bookmark = �纵��˹觷����� Data control - Data1.Recordset.Index = ��˹������ Primary key ���зӧҹ�Ѻ seek - Data1.Recordset.Seek = ��������觼���� Nomatch ��Ҩ�ԧ������ - Data1.Recordset.NoMatch = �Ѻ�Ũҡ��� seek
Bookmark = Data1.Recordset.Bookmark Data1.Recordset.Index = "PrimaryKey" Data1.Recordset.Seek "=", Val(Text4) If Data1.Recordset.NoMatch Then Data1.Recordset.Bookmark = Bookmark Else Command2.Enabled = True Text1.Visible = True Text2.Visible = True Text3.Visible = True End If If MsgBox("Are you sure to delete?", vbYesNo) = vbYes Then ? �������¹�� table ��� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
Download : chap105.zip |
��� Properties of DBGrid,Datasource = data1 ��� Properties of DBGrid,AllowUpdate = false Bookmark = Data1.Recordset.Bookmark Data1.Recordset.Index = "PrimaryKey" Data1.Recordset.Seek "=", Val(Text4) If Data1.Recordset.NoMatch Then Data1.Recordset.Bookmark = Bookmark Else Text1.Visible = True Text2.Visible = True Text3.Visible = True End If
Private Sub DBGrid1_click() ? �������¹�� table ��� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
Download : chap106.zip |
Private Sub Command1_Click() Bookmark = Data1.Recordset.Bookmark Data1.Recordset.Index = "PrimaryKey" Data1.Recordset.Seek "=", Val(InputBox("Get categoryid")) If Data1.Recordset.NoMatch Then MsgBox ("Not found") Data1.Recordset.Bookmark = Bookmark End If End Sub Private Sub Command2_Click() ? �������¹�� table ��� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
Download : chap107.zip |
1. ���͡ Add-Ins �ҡ menu bar �������͡ Add-In manager, VB 6 Data Form Wizard ���� Click ��� Loaded/Unloaded ���ǡ����� OK 2. ���͡ Data form wizard ���¡�� Click ��� Add-Ins, Data Form Wizard..., Next, ���͡ Access ���ǡ����� Next, "C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb", Next, Single record ��� ADO Data control, Next, 㹪�ͧ Record source ���͡ Categories, ���͡ 3 fields �á�Ҵ�ҹ���, next, finish ���� form ��������� project �ͧ��� �ҡ�����ҡ���֡���»��� �����ͧ�֡���� source code �ҡ�����˹����ա�����˹�� ��觼��ͧ���¨ҡ������ҧ������� form1 ������ҡ����
���������������¹ code ��� �����¡���ҧ���� ������Դ��Ҵ�� ok ���� Source code ��� Wizard ���ҧ��� ? �������¹�� table ��� ? ������ҧ��� .mdb ���ͧ ������¡ table �ͧ���ͧ |
|
- ������� products �ͧ nwind.mdb �� 10 fields ���ͧ�� 3 fields - ���ҧ 5 control �ѧ�Ҿ ��� 3 textbox, command ��� adodc - ���͡ ADODC properties ���¡�� Right click �ҡ adodc bar � form : ��ǹ General : ���͡ Use ODBC Data Source Name ������� nwind �ҡ list : ��ǹ RecordSource : ���͡ SQL ���Ǿ���� select * from products - �س���ѵԢͧ text1 ��� DataSource=Adodc1 ��� DataField=ProductID - �س���ѵԢͧ text2 ��� DataSource=Adodc1 ��� DataField=ProductName - �س���ѵԢͧ text3 ��� DataSource=Adodc1 ��� DataField=UnitPrice Source code � command1 Private Sub Command1_Click() Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveFirst End If End Sub ? ���ҧ command2 �繻������͡�Ң�ҧ˹�� ���¤���� moveprevious ? ���ҧ command3 ��� 4 �繻��� movefirst ��� movelast ? ����¹���ҧ�ҡ products ����� � (���ҧ�˹����) |
���� 3 :�к��ҹ�����Ŵ��� DAO |
Download : chap201.zip |
1. click Project, References.. �ҡ menu bar �������� Microsoft DAO 3.51 Object Library ���¡�÷�����ͧ���¶١� check box 2. ���ҧ Textbox ���� Text1 3. ���ҧ CommandButton ���� Command1 4. Copy source code ��ҹ��ҧ �������ǹ�ͧ View code window 5. Run ����¤�Ѻ Source code �����ҹ ? �Ѩ�غѹ�ѧ�����������������ռ� ��䧨֧������� ? ���Ѻ�ӹǹ����¹㹵��ҧ��� � �ٺ�ҧ ? ������ҧ����� field �����ͧ������ 2 ���� 3 �Ԥ�Ѻ |
1. click Project, References.. �ҡ menu bar �������� Microsoft DAO 3.51 Object Library ���¡�÷�����ͧ���¶١� check box 2. ���ҧ Textbox ���� Text1��� Text2 3. ���ҧ CommandButton ���� Command1 ��� Command2 4. Copy source code ��ҹ��ҧ �������ǹ�ͧ View code window 5. Run ����¤�Ѻ Source code �����ҹ ? ����¹�ҡ���ҧ categories �繵��ҧ��� ? ����¹����ʴ�������� msgbox ��� form ���� ? ����¹ �������� ˹�ҷ��ҡ addnew �� edit ���� delete |
Download : vbnwind.zip Program screen Database screen |
? ����¹�ҡ���ҧ categories �繵��ҧ��� ? �����������Ѻ��ا������ |
���� 4 :�� API �ͧ�к� Windows | ������ҧ��ô��Ըջ�С�� API �������¡��� VB ��ͧ�Դ��� WIN32API.TXT ����Ѻ����Դ�����á |
Download : chap301.zip |
������ҧ��ҧ��ҧ���: �����¡�ѧ��ѹ���ӧҹ ������ա�á����� command1 �����觤�����Ѻ text1 �ʴ��ŵ���
Private Declare Function getdiskfreespacea _ Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal _ iprootpathname As String, _ ipsectorspercluster As Long, _ ipbytespersector As Long, _ ipnumberoffreeclusters As Long, _ iptotalnumberofclusters As Long _ ) As Long Private Sub Command1_Click() Text1 = Format(sectors * bytes * freecluster, "##,###") & " Bytes" Text1 = Text1 & "(" & sectors & "*" & bytes & "*" & freecluster & ")" msgbox app.path End Sub ������ҧ 2 : �¡��С�������� ���㹿���� ' in module1 (if in form will be error) Public Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Public Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) ' in form1 End Sub ? �������¹�� drive ��� ���лѨ�غѹ�ѡ������ Drive �ѹ���� ? ������¡ GetSystemInfo �ҡ kernel32 ? �ʴ� Current Directory ���� app.path � text box ? �ͧ���¡�� API �����蹴��Ԥ�Ѻ |
Download : chap302.zip ��� tping.exe |
? ��ҹ����о��ѭ�� �����ѭ������ͧ����ʴ��� ? ����Ѻ�������˹� IP �״�����ҡ��� ������ͧ�����˭� ? ��ҹ���㨵�����ҧ code ��ҧ��ҧ���������ҧ�� Dim buff As String Open "c:\test.txt" For Input As #1 filestr = "" Do Until EOF(1) Line Input #1, TempStr filestr = filestr & TempStr & Chr$(13) & Chr$(10) Loop Close #1 Text1.Text = filestr ' Open App.Path & "\output.txt" For Output As #2 ' Print #2, s_Student, s_Grade |
������ҧ open.php <? $f = fopen("log.txt","a"); fputs($f, $_GET["q"].",".$_GET["n"]."\n"); fclose($f); ?> ������ҧ list.php <? $ar = file("log.txt"); foreach ($ar as $v) echo $v."<br>"; ?> ? ��Ẻ������ �����š� ������������᷺�����繼� ? ���ҧ���� close form �� 1 ���� ? �� ball �������� ���Ҩҡ����� 16 ����� ? ������ open.php ��� list.php �ӧҹ�����Ѻ .MDB ���� MySQL |