PDA

View Full Version : سوال: سوال در مورد ListBox



earse+erse
پنج شنبه 26 آذر 1388, 14:29 عصر
سوال در مورد ListBox

من يه ليست باكس دارم كه تو اون داده هاي عددي است
چه جوري مي تونم عدد هاي توي ليست باكس رو از بزرگ به كوچك داخل 5 ، TextBox بزارم
توي ليست باكس بيشتر از 5 عدد هست


http://www.barnamenevis.org/forum/attachment.php?attachmentid=41324&stc=1&d=1261045664

mpmsoft
پنج شنبه 26 آذر 1388, 15:20 عصر
ابتدا خاصیت Sort لیست باکس رو برابر true کنید
و سپس از آخر آیتم لیست اعداد رو از لیست بخونید و در تکست باکس نشون بدید



For i = List1.ListCount -1 to 0
....
Next

earse+erse
شنبه 28 آذر 1388, 17:51 عصر
مرسي ولي مي تونيد بيشتر توضيح بديد؟

اشكال اين كد چيه؟ چرا كار نمي كنه؟


lbl(0)TO (6) = Textbox



H= List box






Private Sub Form_Load()
For i = 0 To H.ListCount


If H.List(i) > lbl(0).Caption Then
lbl(0).Caption = H.List(i(
ElseIf H.List(i) < lbl(0).Caption And H.List(i) > lbl(1).Caption Then
lbl(1).Caption = H.List(i(
ElseIf H.List(i) < lbl(1).Caption And H.List(i) < lbl(2).Caption Then
lbl(2).Caption = H.List(i(
ElseIf H.List(i) < lbl(2).Caption And H.List(i) > lbl(3).Caption Then
lbl(3).Caption = H.List(i(
ElseIf H.List(i) < lbl(3).Caption And H.List(i) > lbl(4).Caption Then
lbl(4).Caption = H.List(i(
ElseIf H.List(i) < lbl(4).Caption And H.List(i) > lbl(5).Caption Then
lbl(5).Caption = H.List(i(
ElseIf H.List(i) < lbl(5).Caption And H.List(i) > lbl(6).Caption Then
lbl(6).Caption = H.List(i(
End If
Next i

End Sub

parselearn
یک شنبه 29 آذر 1388, 02:28 صبح
يك روش (اما خطا زياد داره)


On Error Resume Next
'List2.Clear
Dim m As Integer, t As Integer
For f = 0 To 4
For j = 0 To List1.ListCount - 1
m = List1.List(0)
For i = 1 To List1.ListCount - 1
If List1.List(i) > m Then
m = List1.List(i)
t = i
End If
Next i

List1.RemoveItem t
List2.AddItem m
TextBox(List2.ListCount - 1).Text = m
If m = List2.List(List2.ListCount - 1) Then Exit For
Next j

Next f

earse+erse
یک شنبه 29 آذر 1388, 18:04 عصر
ازتون متشكرم ولي چيزي كه من مي خواستم دقيقا با اين كد قابل حله




Private Sub Timer1_Timer()


For I = 0 To H.ListCount


If Val(H.List(I)) > lbl(0).Caption Then
lbl(0).Caption = H.List(I)
End If


If Val(H.List(I)) < lbl(0).Caption And Val(H.List(I)) > lbl(1).Caption Then
lbl(1).Caption = H.List(I)
End If


If Val(H.List(I)) < lbl(1).Caption And Val(H.List(I)) > lbl(2).Caption Then
lbl(2).Caption = H.List(I)
End If


If Val(H.List(I)) < lbl(2).Caption And Val(H.List(I)) > lbl(3).Caption Then
lbl(3).Caption = H.List(I)
End If


If Val(H.List(I)) < lbl(3).Caption And Val(H.List(I)) > lbl(4).Caption Then
lbl(4).Caption = H.List(I)
End If


Next I


End Sub





بايد از يه تايمر استفاده كنيم كدش هم بالا هست فكر كنم مفهوم باشه