标题:求问各位大神如何做下面的题目
只看楼主
三竖
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-5-15
 问题点数:0 回复次数:2 
求问各位大神如何做下面的题目
2020-05-15 20:28
gbhytg
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2020-6-1
得分:0 
你可以试试这个,使用vb2012做的
Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Focus()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1.TextLength > 0 Then
            ListBox1.Items.Add(TextBox1.Text)
            TextBox1.Clear()
            TextBox1.Focus()
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim i As Integer = 0
        If TextBox1.TextLength > 0 Then
            If ListBox1.Items.Count > 0 Then
                For i = 0 To ListBox1.Items.Count - 1
                    ListBox1.SelectedIndex = i
                    ListBox1.Items.Remove(TextBox1.Text)
                    Exit For
                Next
            End If
        End If
    End Sub
End Class
2020-06-02 18:24
moou
Rank: 2
等 级:论坛游民
威 望:1
帖 子:22
专家分:40
注 册:2018-8-15
得分:0 
程序代码:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i = 0 To 2
            ListBox1.Items.Add(InputBox("添加第" & i + 1 & "个项目"))
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim inputStr As String = InputBox("输入要删除的数据")

        For i = 0 To ListBox1.Items.Count - 1
            If ListBox1.Items(i).ToString = inputStr Then
                ListBox1.Items.RemoveAt(i)
                Exit For
            End If
        Next
    End Sub


我看的描述为啥跟下面的Text1没啥关系啊
2020-09-01 14:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-501627-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.063482 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved