Показать сообщение отдельно
Старый 16.04.2019, 14:13   #1 (permalink)
Syringe
Новичок
 
Регистрация: 16.04.2019
Сообщений: 2
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
По умолчанию Настроить кнопки добавления и изменения записи

Добрый день! Пишу работу на vb, но не получается настроить кнопки добавления и изменения записи. Кнопку удаления как то написал, остальное не получается. Ниже сама программа.
Begin VB.Form Form1
Caption = "ATM Tools"
ClientHeight = 6045
ClientLeft = 120
ClientTop = 465
ClientWidth = 9180
LinkTopic = "Form1"
ScaleHeight = 6045
ScaleWidth = 9180
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command6
Caption = "Очистить список"
Height = 375
Left = 2880
TabIndex = 10
Top = 4440
Width = 3375
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 375
Left = 2880
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 4440
Visible = 0 'False
Width = 3375
End
Begin VB.CommandButton Command5
Caption = "Удалить"
Height = 375
Left = 2880
TabIndex = 9
Top = 5520
Width = 3375
End
Begin VB.CommandButton Command4
Caption = "Изменить"
Height = 375
Left = 6480
TabIndex = 8
Top = 5520
Width = 2535
End
Begin VB.CommandButton Command3
Caption = "Добавить"
Height = 375
Left = 120
TabIndex = 7
Top = 5520
Width = 2535
End
Begin VB.TextBox Text4
Height = 285
Left = 6960
TabIndex = 6
Text = "Balance"
Top = 5040
Width = 2055
End
Begin VB.TextBox Text3
Height = 285
Left = 4680
TabIndex = 5
Text = "Status"
Top = 5040
Width = 2055
End
Begin VB.TextBox Text2
Height = 285
Left = 2400
TabIndex = 4
Text = "Code"
Top = 5040
Width = 2055
End
Begin VB.TextBox Text1
Height = 285
Left = 120
TabIndex = 3
Text = "Name"
Top = 5040
Width = 2055
End
Begin VB.CommandButton Command2
Caption = "Пользователи"
Height = 375
Left = 6480
TabIndex = 2
Top = 4440
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "Банкоматы"
Height = 375
Left = 120
TabIndex = 1
Top = 4440
Width = 2535
End
Begin VB.ListBox List1
Height = 4155
Left = 120
TabIndex = 0
Top = 120
Width = 8895
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim indexList As Integer
Dim pick As String

Private Sub Command1_Click()
Dim countItems, i As Integer
Dim textList As String

pick = "banks"

Text1.Text = "Name"
Text2.Text = "Code"
Text3.Text = "Status"
Text4.Text = "Balance"

Data1.RecordSource = "Bank"
Data1.Refresh

List1.Clear

Data1.Recordset.MoveLast
countItems = Data1.Recordset.RecordCount
Data1.Recordset.MoveFirst

For i = 1 To countItems
textList = Data1.Recordset.Fields("Name") + " | Code: " + Data1.Recordset.Fields("Code") + " | Status: " + Data1.Recordset.Fields("Status") + " | " + Data1.Recordset.Fields("Balance")
List1.AddItem (textList)
Data1.Recordset.MoveNext
Next i
End Sub

Private Sub Command2_Click()
Dim countItems, i As Integer
Dim textList As String

pick = "users"

Text1.Text = "NO"
Text2.Text = "CVV"
Text3.Text = "Exp"
Text4.Text = "Type"

Data1.RecordSource = "Users"
Data1.Refresh

List1.Clear

Data1.Recordset.MoveLast
countItems = Data1.Recordset.RecordCount
Data1.Recordset.MoveFirst

For i = 1 To countItems
textList = Data1.Recordset.Fields("NO") + " | CVV: " + Data1.Recordset.Fields("CVV") + " | Exp: " + Data1.Recordset.Fields("Exp") + " | " + Data1.Recordset.Fields("Type")
List1.AddItem (textList)
Data1.Recordset.MoveNext
Next i
End Sub

Private Sub Command3_Click()
If (pick = "users") Then

End If

If (pick = "banks") Then

End If
End Sub

Private Sub Command4_Click()
MsgBox "Запись изменена!", vbInformation, "Изменение"
End Sub

Private Sub Command5_Click()
Dim i As Integer

Data1.Recordset.MoveFirst

For i = 0 To indexList - 1
Data1.Recordset.MoveNext
Next i

Data1.Recordset.Delete
Data1.Refresh
List1.RemoveItem (indexList)

MsgBox "Запись удалена!", vbInformation, "Удаление"
End Sub

Private Sub Command6_Click()
List1.Clear
End Sub

Private Sub Form_Load()
Data1.DatabaseName = App.Path + "\BankDB.mdb"
End Sub

Private Sub List1_Click()
indexList = List1.ListIndex

Data1.Recordset.MoveFirst

For i = 0 To indexList - 1
Data1.Recordset.MoveNext
Next i

If (pick = "banks") Then
Text1.Text = Data1.Recordset.Fields("Name")
Text2.Text = Data1.Recordset.Fields("Code")
Text3.Text = Data1.Recordset.Fields("Status")
Text4.Text = Data1.Recordset.Fields("Balance")
End If

If (pick = "users") Then
Text1.Text = Data1.Recordset.Fields("NO")
Text2.Text = Data1.Recordset.Fields("CVV")
Text3.Text = Data1.Recordset.Fields("Exp")
Text4.Text = Data1.Recordset.Fields("Type")
End If
End Sub
Syringe вне форума   Ответить с цитированием
Ads

Яндекс

Member
 
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070