ND1

Dim db As Database
Dim rec As Recordset

Private Sub cmdAtsaukti_Click()
Unload Me
End Sub

Private Sub cmdTvirtinti_Click()
If txtVardas.Text = “” Then
MsgBox “Klaida”, vbOKOnly, “Netaisingai!”
Exit Sub
Else
If txtSlapt1.Text <> txtSlapt2.Text Then
MsgBox “Netaisingai!”, vbOKOnly, “Klaida”
Exit Sub
Else
MsgBox “Jusu vardas yra ” & txtVardas.Text & Chr(13) & _
“Jūsų slaptažodis yra ” & txtSlapt2.Text, vbInformation, “Registracija”

End If
End If
Dim sql As String
sql = “Select RegVardas From Magistrantai Where RegVardas = ‘” & txtVardas & “‘”
Set rec = db.OpenRecordset(“Select RegVardas From Magistrantai Where RegVardas = ‘” & txtVardas & “‘”)
If rec.RecordCount = 0 Then
‘MsgBox “Gerai”, vbOKOnly
rec.Close
Set rec = db.OpenRecordset(“Select RegVardas, Slaptazodis From Magistrantai Where ID = 1 “)
rec.Edit
rec!RegVardas = txtVardas.Text
rec!Slaptazodis = txtSlapt2.Text
rec.Update
rec.Close
MsgBox Len(txtSlapt1.Text)
MsgBox “Jusu registracijos vardas ” & txtVardas.Text & ” ir slaptažodis ” & Kartoti(“*”, Len(txtSlapt1.Text)) & ” ivesti į duomeų bazē. “, vbOKOnly, “Registracija”
Else
MsgBox “Pasirinkite kita naudotojo varda”, vbOKOnly
End If
End Sub

Function Kartoti(ByVal s As String, ByVal Kiek As Integer) As String
Dim i As Integer
Kartoti = “”
For i = 1 To Kiek
Kartoti = Kartoti & s
i = i + 1
Next i
End Function

Private Sub UserForm_Initialize()
Set db = OpenDatabase(“C:\Sliv\db”)
End Sub

Private Sub UserForm_Terminate()
db.Close
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.