注册 登录
编程论坛 VB6论坛

(vb6.0)遇到的几个难题

nbatu3065159 发布于 2015-01-20 13:32, 648 次点击
我是新手 做个简单的程序如下
   有6个textBox  名称分别是text1 text2 text3 text4 text5  text6     
   有1个commandButton    名称是command1
任务1:text1 text2 text3 text4 text5(只能输入2个数字    这个妹子以解决)
任务2:text1 text2 text3 text4 text5(只能输入01——11) 这个不会
任务3:  点一下command1  
If Text1.Text = "03" Then Text6.Text = "01 02 03"
    If Text1.Text = "04" Then Text6.Text = "01 03 04"
    If Text1.Text = "05" Then Text6.Text = "01 04 05   02 03 05"
    If Text1.Text = "06" Then Text6.Text = "01 05 06   02 04 06"
    If Text1.Text = "07" Then Text6.Text = "01 06 07   02 05 07    03 04 07"
    If Text1.Text = "08" Then Text6.Text = "01 07 08   02 06 08    03 05 08"
    If Text1.Text = "09" Then Text6.Text = "01 08 09   02 07 09    03 06 09   04 05 09"
    If Text1.Text = "10" Then Text6.Text = "01 09 10   02 08 10    03 07 10   04 06 10"
    If Text1.Text = "11" Then Text6.Text = "01 10 11   02 09 11    03 08 11   04 07 11   05 06 11"
If Text2.Text = "03" Then Text6.Text = "01 02 03"
    If Text2.Text = "04" Then Text6.Text = "01 03 04"
    If Text2.Text = "05" Then Text6.Text = "01 04 05   02 03 05"
    If Text2.Text = "06" Then Text6.Text = "01 05 06   02 04 06"
    If Text2.Text = "07" Then Text6.Text = "01 06 07   02 05 07    03 04 07"
    If Text2.Text = "08" Then Text6.Text = "01 07 08   02 06 08    03 05 08"
    If Text2.Text = "09" Then Text6.Text = "01 08 09   02 07 09    03 06 09   04 05 09"
    If Text2.Text = "10" Then Text6.Text = "01 09 10   02 08 10    03 07 10   04 06 10"
    If Text2.Text = "11" Then Text6.Text = "01 10 11   02 09 11    03 08 11   04 07 11   05 06 11"
If Text3.Text = "03" Then Text6.Text = "01 02 03"
    If Text3.Text = "04" Then Text6.Text = "01 03 04"
    If Text3.Text = "05" Then Text6.Text = "01 04 05   02 03 05"
    If Text3.Text = "06" Then Text6.Text = "01 05 06   02 04 06"
    If Text3.Text = "07" Then Text6.Text = "01 06 07   02 05 07    03 04 07"
    If Text3.Text = "08" Then Text6.Text = "01 07 08   02 06 08    03 05 08"
    If Text3.Text = "09" Then Text6.Text = "01 08 09   02 07 09    03 06 09   04 05 09"
    If Text3.Text = "10" Then Text6.Text = "01 09 10   02 08 10    03 07 10   04 06 10"
    If Text3.Text = "11" Then Text6.Text = "01 10 11   02 09 11    03 08 11   04 07 11   05 06 11"
If Text5.Text = "03" Then Text6.Text = "01 02 03"
    If Text5.Text = "04" Then Text6.Text = "01 03 04"
    If Text5.Text = "05" Then Text6.Text = "01 04 05   02 03 05"
    If Text5.Text = "06" Then Text6.Text = "01 05 06   02 04 06"
    If Text5.Text = "07" Then Text6.Text = "01 06 07   02 05 07    03 04 07"
    If Text5.Text = "08" Then Text6.Text = "01 07 08   02 06 08    03 05 08"
    If Text5.Text = "09" Then Text6.Text = "01 08 09   02 07 09    03 06 09   04 05 09"
    If Text5.Text = "10" Then Text6.Text = "01 09 10   02 08 10    03 07 10   04 06 10"
    If Text5.Text = "11" Then Text6.Text = "01 10 11   02 09 11    03 08 11   04 07 11   05 06 11"
If Text4.Text = "03" Then Text6.Text = "01 02 03"
    If Text4.Text = "04" Then Text6.Text = "01 03 04"
    If Text4.Text = "05" Then Text6.Text = "01 04 05   02 03 05"
    If Text4.Text = "06" Then Text6.Text = "01 05 06   02 04 06"
    If Text4.Text = "07" Then Text6.Text = "01 06 07   02 05 07    03 04 07"
    If Text4.Text = "08" Then Text6.Text = "01 07 08   02 06 08    03 05 08"
    If Text4.Text = "09" Then Text6.Text = "01 08 09   02 07 09    03 06 09   04 05 09"
    If Text4.Text = "10" Then Text6.Text = "01 09 10   02 08 10    03 07 10   04 06 10"
    If Text4.Text = "11" Then Text6.Text = "01 10 11   02 09 11    03 08 11   04 07 11   05 06 11"
我想做的是点一下command1     text1 text2 text3 text4 text5的结果 都显示在text6.text(未解决)
任务4:   text6  每行只能输入8个字符,多少行不限制(未解决)
以上就是妹子的难题  希望高手给与解决(如果是要微信号 QQ号 手机号的请点关闭)
5 回复
#2
wp2319572015-01-20 13:50
明明注册的是男士,咋么说是妹子呢
#3
lianyicq2015-01-22 11:38
主要考虑任务2,任务3的逻辑条件自己考虑。
程序代码:
Option Explicit
Dim state As Integer

Private Sub Form_Load()
Text1.MaxLength = 2
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyBack Then
  If state = 1 Then state = 0
  Exit Sub
End If
If state = 1 And Text1.Text = "0" And KeyAscii > 48 And KeyAscii < 59 Then Exit Sub
If state = 1 And Text1.Text = "1" And (KeyAscii = 48 Or KeyAscii = 49) Then Exit Sub
If Text1.Text = "" And (KeyAscii = 48 Or KeyAscii = 49) Then state = 1: Exit Sub
KeyAscii = 0

End Sub
测试代码,看明白后,有小问题自己思考解决。
#4
yangfrancis2015-01-22 19:59
Private Sub Text1_TextChange()
if Len(Text1.text)>2 or Val(Text1.text)>11 or Val(Text1.text)<1 then
   Text1.text="":Text1.SetFocus
end if
End Sub
试一下看行不行
#5
yangfrancis2015-01-22 20:03
Text6.Text=Text1.Text+" "+Text2.Text+" "+Text3.Text+Chr(13)+Chr(10)+Text4.Text+" "+Text5.Text
#6
工长562015-01-23 22:19
在认真的学习。
1