vb 组合框
建立简单组合框,在组合框的文本框中输入数字字符,按回车键后加入到组合框的列表框内,单击交换按钮,列表框中最小项目与第0个项目交换,最大项目和最后项目交换1.~~能在解释详...
建立简单组合框,在组合框的文本框中输入数字字符,按回车键后加入到组合框的列表框内,单击交换按钮,列表框中最小项目与第0 个项目交换,最大项目和最后项目交换
1.~~能在解释详细点不?
2。最大项目和最后项目 咋没换呢~~ 展开
1.~~能在解释详细点不?
2。最大项目和最后项目 咋没换呢~~ 展开
1个回答
展开全部
Dim myX()
Dim n As Long
Dim myMin
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
List1.AddItem Combo1.Text
n = n + 1
ReDim Preserve myX(n)
myX(n - 1) = Combo1.Text
If n = 1 Then myMin = Val(Combo1.Text)
If Val(Combo1.Text) < myMin Then
myMin = Val(Combo1.Text)
End If
Combo1.Text = ""
End If
End Sub
Private Sub Command1_Click()
Dim x0
Dim i As Long
Dim myStr As String
myStr = Join(myX, ",")
If LenB(myStr) > 0 Then
x0 = myX(0)
myX(0) = myMin
Debug.Print x0, myMin, UBound(myX)
For i = 1 To UBound(myX) - 1
If Val(myX(i)) = Val(myMin) Then
myX(i) = x0
Exit For
End If
Next i
List1.Clear
For i = 0 To UBound(myX) - 1
List1.AddItem myX(i)
Next i
End If
End Sub
Private Sub Form_Load()
Combo1.Text = ""
n = 0List1.Clear
myMin = 0
End Sub
Dim n As Long
Dim myMin
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
List1.AddItem Combo1.Text
n = n + 1
ReDim Preserve myX(n)
myX(n - 1) = Combo1.Text
If n = 1 Then myMin = Val(Combo1.Text)
If Val(Combo1.Text) < myMin Then
myMin = Val(Combo1.Text)
End If
Combo1.Text = ""
End If
End Sub
Private Sub Command1_Click()
Dim x0
Dim i As Long
Dim myStr As String
myStr = Join(myX, ",")
If LenB(myStr) > 0 Then
x0 = myX(0)
myX(0) = myMin
Debug.Print x0, myMin, UBound(myX)
For i = 1 To UBound(myX) - 1
If Val(myX(i)) = Val(myMin) Then
myX(i) = x0
Exit For
End If
Next i
List1.Clear
For i = 0 To UBound(myX) - 1
List1.AddItem myX(i)
Next i
End If
End Sub
Private Sub Form_Load()
Combo1.Text = ""
n = 0List1.Clear
myMin = 0
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询