易截截图软件、单文件、免安装、纯绿色、仅160KB

关于VB中的列表框的问题

一道VB小程序
有两个列表框list1、 list2 。list1中初始化有15个不同的字母,而list2中是空白的 还有一个按钮command1,选中list1中的任意多个项目 然后点击按钮command1,则在list2中显示list1中被选中的项目。当多次选中list1中的同个项目时候,比如list1中的a被选中了3次 那么在list2中就有3个a.
我想问:怎样编写代码实现当list1中的项目不管被选中多少次,在list2中相同的只出现一次,即在list2中不要出现重复的字母。怎样实现呢?
思路:在command1中,被选中的项目存入数组变量sDate,循环该数组变量,里边嵌套list2的项目做循环,如果有相同的就不再往list2插入
dim b as boolean
for i =0 to ubound(sDate)
  for j =1 to list2.ListCount
      if sDate(i)= list2.list(j) then b=true
  next j
  if b=false then
      list2.AddItem =sDate(i)
  else
      b=false
  end if
next i

VB code:
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim b As Boolean

For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
b = True
For j = 0 To List2.ListCount - 1
If List1.List(i) = List2.List(j) Then
b = False
Exit For
End If
Next j
If b Then List2.AddItem (List1.List(i))


相关问答:

vb打印问题


Printer.ScaleMode = 6
6表示毫米
Printer.PaperSize = vbPRPSA4

'初始坐标
x = 1
y = 4


'最大的线筐
Printer.DrawStyle = 0
Printer.Line (x, y)-(x + 132.5, y) ......

vb打印问题

大家好,问个vb打印问题


printer.print "dsff"
.....
....


Printer.EndDoc


打印成功后我将执行

sqlstr = "update vc_yh set pr=' 已打印 ', ......

为何用vb api获取的窗口标题为空,而SPY++却可以

VB中callbacke function 如下:
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    Dim slength As Long, WndTitle As String ' title bar text length an ......

vb如何调用Illustrator(此前Illustrator未启动)?

请教一下:我用vb写了一个调用Illustrator的测试程序,代码很简单:Private Sub Command1_Click()
Dim app As New Illustrator.Application
Dim doc As Illustrator.Document
Dim thislayer As Illustrator.Layer ......

VB标题栏 动态显示

我在窗体正常运行的情况下 标题栏上可以动态显示数值

可是点击最小化按钮的后 ,在任务栏上的标题上就不变了?

怎么办 

别折腾这些花架子,没意义

不会吧?
VB code:
Private Su ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号