有控件combo1、combo2、combo3、combo4、text1、text2、text3、list1和command1比如:combo1的内容为B.3,combo2的内容为F.4,combo3的内容为05,combo4的内容为1.8
text1的内容为001,text2的内容为012。现在点击command1,要求:
text3的显示内容为:
BF0518001,BF0518002,BF0518003,BF0518004,BF0518005,BF0518006,BF0518007,BF0518008,BF0518009,BF0518010,BF0518011,BF0518012,list1的显示内容为:
BF0518001  0
BF0518002  1
BF0518003  2
BF0518004  3
BF0518005  4
BF0518006  5
BF0518007  6
BF0518008  7
BF0518009  8
BF0518010  9
BF0518011  10
BF0518012  11不知道能不能实现,本人比较菜,请好心人给出代码,不胜感激。

解决方案 »

  1.   

    Private Sub Command1_Click()
    Dim i As Integer
    Dim iCtr As String
        iCtr = Mid(Combo1.Text, 1, 1) & Mid(Combo2.Text, 1, 1) & Combo3.Text & Replace(Combo4.Text, ".", "")
        Debug.Print iCtr
        Text3.Text = ""
        list1.Clear
        For i = Int(Text1.Text) To Int(Text2.Text)
            Text3.Text = Text3.Text & "," & iCtr & Format(i, "000")
            With List1
                .AddItem iCtr & Format(i, "000") & " " & i - 1
            End With
        Next i
        Text3.Text = Mid(Text3.Text, 2, Len(Text3.Text))
      
    End Sub
      

  2.   

    还有个小问题,list1中的第二个字段只要显示从0开始,比如text1为101,text2为112,list1
    显示的是:
    BF0518101 0
    BF0518102 1
    BF0518103 2
    BF0518104 3
    BF0518105 4
    BF0518106 5
    BF0518107 6
    BF0518108 7
    BF0518109 8
    BF0518110 9
    BF0518111 10
    BF0518112 11谢谢
      

  3.   


    Private Sub Command1_Click()
     Dim i As Integer, tmp1 As String, tmp2 As String
     For i = Val(Text1) To Val(Text2)
         tmp1 = Left(Combo1, 1) & Left(Combo2, 1) & Combo3 & Replace(Combo4, ".", "") & Format(i, "000")
         tmp2 = tmp2 & tmp1 & ","
         List1.AddItem tmp1 & " " & (i - 1)
     Next
     Text3 = Left(tmp2, Len(tmp2) - 1)
    End SubPrivate Sub Form_Load()
     Combo1 = "B.3"
     Combo2 = "F.4"
     Combo3 = "05"
     Combo4 = "1.8"
     Text1 = "001"
     Text2 = "012"
     Text3 = ""
     
    End Sub
      

  4.   


    Private Sub Command1_Click()
     Text3 = "": List1.Clear
     Dim i As Integer, tmp1 As String, tmp2 As String, n As Integer
     For i = Val(Text1) To Val(Text2)
         tmp1 = Left(Combo1, 1) & Left(Combo2, 1) & Combo3 & Replace(Combo4, ".", "") & Format(i, "000")
         tmp2 = tmp2 & tmp1 & ","
         List1.AddItem tmp1 & " " & n
         n = n + 1
     Next
     Text3 = Left(tmp2, Len(tmp2) - 1)
    End SubPrivate Sub Form_Load()
     Combo1 = "B.3"
     Combo2 = "F.4"
     Combo3 = "05"
     Combo4 = "1.8"
     Text1 = "001"
     Text2 = "012"
     Text3 = ""
     
    End Sub
      

  5.   


    还有个问题,list1中的第二个字段只要显示从0开始,比如text1为101,text2为112,list1
    显示的是:
    BF0518101 0
    BF0518102 1
    BF0518103 2
    BF0518104 3
    BF0518105 4
    BF0518106 5
    BF0518107 6
    BF0518108 7
    BF0518109 8
    BF0518110 9
    BF0518111 10
    BF0518112 11
    这个怎么解决??