visual basic code
visual basic code
txt)
1. Open Notepad.
2. Save the file as users.txt in the same folder as your VB6 project.
admin,12345
user1,password
fileNum = FreeFile
loginSuccess = False
loginSuccess = True
Exit Do
End If
Loop
Close #fileNum
If loginSuccess Then
frmLogin.Hide
Else
End If
End Sub
This code checks the entered credentials against the records in users.txt.
---
End Sub
we will use text files (.txt) as a database. This method reads, writes, updates, and deletes
records using text file operations.
---
1. Open Notepad.
2. Save the file as students.txt in the same folder as your VB6 project.
S002,Jane Smith,22,Mathematics
Each line represents a student's record, with fields separated by commas (,).
fileNum = FreeFile
studentData = txtID.Text & "," & txtName.Text & "," & txtAge.Text & "," & txtCourse.Text
Close #fileNum
MsgBox "Record Inserted Successfully!", vbInformation, "Success"
txtID.Text = ""
txtName.Text = ""
txtAge.Text = ""
txtCourse.Text = ""
End Sub
fileNum = FreeFile
found = False
txtName.Text = studentInfo(1)
txtAge.Text = studentInfo(2)
txtCourse.Text = studentInfo(3)
found = True
Exit Do
End If
Loop
Close #fileNum
End If
End Sub
---
fileNum = FreeFile
tempFile = FreeFile + 1
updated = False
Print #tempFile, txtID.Text & "," & txtName.Text & "," & txtAge.Text & "," &
txtCourse.Text
updated = True
Else
End If
Loop
Close #fileNum
Close #tempFile
If updated Then
Else
End If
End Sub
fileNum = FreeFile
tempFile = FreeFile + 1
Else
End If
Loop
Close #fileNum
Close #tempFile
If deleted Then
Else
End If
End Sub