用VB编一个小程序,输入文本,查找一个列表中该文本对应项,可以修改等。
输入文本,查找一个列表(可以不是数据库)中该文本对应项,可以修改、增加、删除等。封装在一个可执行程序内,如何实现?谢谢!...
输入文本,查找一个列表(可以不是数据库)中该文本对应项,可以修改、增加、删除等。封装在一个可执行程序内,如何实现?谢谢!
展开
1个回答
展开全部
一个列表框,三个按钮,然后粘贴代码,不明白的百度HI我
Option Explicit
Private Sub Command1_Click()
Dim s As String
s = InputBox("输入新增项目内容")
List1.AddItem s
End Sub
Private Sub Command2_Click()
Dim s As String
If List1.ListIndex >= 0 Then
s = InputBox("输入修改项目内容")
List1.List(List1.ListIndex) = s
End If
End Sub
Private Sub Command3_Click()
If List1.ListIndex >= 0 Then
List1.RemoveItem List1.ListIndex
End If
End Sub
Private Sub Command4_Click()
Dim s As String
s = InputBox("输入查找内容")
Dim i As Integer
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), s) > 0 Then
List1.ListIndex = i
MsgBox "找到"
Exit Sub
End If
Next i
MsgBox "没找到"
End Sub
Private Sub Form_Load()
Command1.Caption = "增加"
Command2.Caption = "修改"
Command3.Caption = "删除"
Command4.Caption = "查找"
End Sub
Option Explicit
Private Sub Command1_Click()
Dim s As String
s = InputBox("输入新增项目内容")
List1.AddItem s
End Sub
Private Sub Command2_Click()
Dim s As String
If List1.ListIndex >= 0 Then
s = InputBox("输入修改项目内容")
List1.List(List1.ListIndex) = s
End If
End Sub
Private Sub Command3_Click()
If List1.ListIndex >= 0 Then
List1.RemoveItem List1.ListIndex
End If
End Sub
Private Sub Command4_Click()
Dim s As String
s = InputBox("输入查找内容")
Dim i As Integer
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), s) > 0 Then
List1.ListIndex = i
MsgBox "找到"
Exit Sub
End If
Next i
MsgBox "没找到"
End Sub
Private Sub Form_Load()
Command1.Caption = "增加"
Command2.Caption = "修改"
Command3.Caption = "删除"
Command4.Caption = "查找"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询