|
VB6 Connect to MS-Access with Password (Visual Basic 6) |
|
|
|
សរសេរដោយ Setha IECH
|
|
អង្គារ, 11 ឧសភា 2010 08:36 |
|
Dim db As New ADODB.Connection Dim rec As New ADODB.Recordset Dim recCount As Integer db.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=MS Access Database;" & _ "Initial Catalog=" & App.Path & "\dbstudent.mdb; Password=12345" db.Open rec.Open "SELECT * FROM tblStudent ORDER BY [name]", db, 3, 2 recCount = rec.RecordCount .............................................. |
|
|
Create Hang Man Game in Visual Basic 6 |
|
|
|
សរសេរដោយ Setha IECH
|
|
ពុធ, 05 ឧសភា 2010 13:44 |
|
----------------------------------------------- Dim i As Integer: i = 1 Dim isCorrectWord As Boolean: isCorrectWord = False Dim MyWord As String While Mid(MyStr, i, 1) & "" <> "" If Mid(MyStr, i, 1) = Right(txtLetter.Text, 1) Then MyWord = MyWord & Right(txtLetter.Text, 1) If Mid(lblWordGuess.Caption, i, 1) <> _ Right(txtLetter.Text, 1) Then _ isCorrectWord = True Else MyWord = MyWord & Mid(lblWordGuess.Caption, i, 1) End If i = i + 1 Wend txtTotalGuess = txtTotalGuess + 1 If Not isCorrectWord Then txtWrongGuess = txtWrongGuess + 1 If txtWrongGuess = 1 Then shapeHead.Visible = True If txtWrongGuess = 2 Then lineEye1.Visible = True: lineEye2.Visible = True lineEye3.Visible = True: lineEye4.Visible = True lineNose.Visible = True: lineMouth.Visible = True End If If txtWrongGuess = 3 Then lineNeck.Visible = True If txtWrongGuess = 4 Then lineHandL.Visible = True If txtWrongGuess = 5 Then lineHandR.Visible = True If txtWrongGuess = 6 Then lineBody.Visible = True If txtWrongGuess = 7 Then lineLegL.Visible = True If txtWrongGuess = 8 Then lineLegR.Visible = True End If --------------------------------------------------- Download Source Code Here |
|
Create Table in Microsoft Access From Visual Basic 6.0 |
|
|
|
សរសេរដោយ Administrator
|
|
អង្គារ, 27 មេសា 2010 09:37 |
|
1. Create one database in Microsoft Access named: a.mdb and place to C:\ 2. Create project in Visual Basic 6.0 Dim db as DAO.Database Dim tbd As DAO.TableDef set db=OpenDatabase("C:\a.mdb") Set tbd = db.CreateTableDef("tblTest") With tbd .Fields.Append .CreateField("ID", dbText) .Fields.Append .CreateField("Name", dbText) .Fields.Append .CreateField("Sex", dbText) .Fields.Append .CreateField("DOB", dbDate) End With db.TableDefs.Append tbd |
|
Create Typing in VB6 |
|
|
|
សរសេរដោយ Setha IECH
|
|
អង្គារ, 27 មេសា 2010 09:25 |
Tips: Create one form and create Button Array for each letter as on keyboard layout and create one RichTextBox for the words to type. 
Private strWord As String Private curInd As Integer Private Sub HighLightKey(ByVal parLetter As String, ByVal par_color As Long) Dim i As Integer If (Asc(parLetter) >= 65 And Asc(parLetter) <= 65 + 25) Or _ (Asc(parLetter) > 97 And Asc(parLetter) < 97 + 25) Then For i = 0 To 25 If Asc(parLetter) = 65 + i Or Asc(parLetter) = 97 + i Then cmdLetter(i).BackColor = par_color End If Next ElseIf Asc(parLetter) = 13 Then cmdLetter(27).BackColor = par_color ElseIf Asc(parLetter) = 32 Then cmdLetter(26).BackColor = par_color End If End Sub Private Sub ChangeHighLightKey() Dim strPreviousLetter As String Dim strLetter As String ' If curInd > 0 Then strPreviousLetter = Mid(strWord, curInd, 1) HighLightKey strPreviousLetter, &H8000000F End If ' If curInd < Len(strWord) Then strLetter = Mid(strWord, curInd + 1, 1) HighLightKey strLetter, &HFF00& End If End Sub ................................................................................. Download Source Code Here |
|
Export Data from VB 6 to Microsoft Excel |
|
|
|
សរសេរដោយ Administrator
|
|
សុក្រ, 25 ធ្នូ 2009 14:12 |
ជាដំបូងអនុវត្តតាមការណែនាំខាងក្រោម៖ - បង្កើត Form មួយដែលមានឈ្មោះ Form1 ជាឧទាហរណ៍
- យក ListView Control មកគូសលើ Form1
- ផ្ដល់តម្លៃឱ្យ Property lvwReport ជា View
- បង្កើតជួរឈរ 5 ក្នុង ListView ដែលមានឈ្មោះរៀង ID, Name, Gender, Phone និង Address
- គូសប៊ូតុងចំនួនពីរដោយដាក់ឈ្មោះរៀង btnExport និង btnClose
- On Event Form Load: ដាក់ទិន្នន័យចូលក្នុង ListView ចំនួន ១០ ជួរដេក
Private Sub Form_Load() Me.lvwData.View = lvwReport ' Dim i As Integer For i = 1 To 10 With Me.lvwData.ListItems.Add(, , i) .SubItems(1) = "Name " & i .SubItems(2) = "M" .SubItems(3) = "012" .SubItems(4) = "Phnom Penh" End With Next End Sub - On btnExport Click: ចុចប៊ូតុង btnExport ដើម្បីបញ្ជូនទិន្នន័យក្នុង List ទៅ Excel
Private Sub cmdExport_Click() Dim ExcelApp As Object, ExcelBook As Object Dim ExcelSheet As Object Dim i As Integer Dim j As Integer Dim rowCount As Integer 'create object of excel Set ExcelApp = CreateObject("Excel.Application") Set ExcelBook = ExcelApp.WorkBooks.Add Set ExcelSheet = ExcelBook.WorkSheets(1) ' With ExcelSheet For i = 1 To Me.lvwData.ListItems.Count ' rowCount = rowCount + 1 .cells(rowCount, 1) = lvwData.ListItems(i).Text For j = 1 To lvwData.ColumnHeaders.Count - 1 .cells(rowCount, j + 1) = lvwData.ListItems(i).SubItems(j) Next Next End With ExcelApp.Visible = True 'set page margin ExcelSheet.PageSetup.PaperSize = 9 ExcelSheet.PageSetup.LeftMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.RightMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.TopMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.BottomMargin = ExcelApp.InchesToPoints(0.3) ExcelSheet.PageSetup.CenterHorizontally = True ' Set ExcelSheet = Nothing Set ExcelBook = Nothing Set ExcelApp = Nothing End Sub
Download Source Code |
|
|
|
|
|