[VB6 ] 關於 listbox 問題

看板Visual_Basic作者 (幽紀川)時間16年前 (2009/06/17 12:11), 編輯推噓1(105)
留言6則, 2人參與, 最新討論串1/1
請輸入專案類型(網站專案或者應用程式專案):Visual Basic 6 目前有以下物件 TextBox1、ListBox1、Button1(replace)、Button2(next) 原本listbox 的清單 是a、b、c 可以直接在ListBox1上點選項目,也可以用Button2(Next)選下一個項目。 若直接用滑鼠點選ListBox1上的項目,執行Button(Next)時,可能不會跳到下一個項目。 請問程式如何修改? 目的功能:在TextBox1上輸入一段文字,按下 "replace" Button,ListBox1被選到的文字改為 TextBox1上的文字。 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.SelectedIndex = Sel Sel += 1 If sel = ListBox1.Items.Count Then sel = 0 End Sub 附上原程式網址 http://0rz.tw/9hofh (已修正空間,造成不便,深感抱歉) - ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.127.115.61

06/18 08:38, , 1F
網址有問題
06/18 08:38, 1F
※ 編輯: believe255 來自: 140.127.115.61 (06/18 09:36)

06/18 11:53, , 2F
邏輯問題!
06/18 11:53, 2F

06/18 11:54, , 3F
sel = ListBox1.SelectedIndex
06/18 11:54, 3F

06/18 11:54, , 4F
sel += 1
06/18 11:54, 4F

06/18 11:54, , 5F
If sel >= ListBox1.Items.Count Then sel = 0
06/18 11:54, 5F

06/18 11:55, , 6F
ListBox1.SelectedIndex = sel
06/18 11:55, 6F
文章代碼(AID): #1AE6pmgl (Visual_Basic)