当前位置:编程学习 > VB >>

VB编程问题

VB里怎么按一下按钮就添加1个TEXT?而且可以拖动到指定位置?

VB里在TEXT1里填写1,TEXT2里填写2,TEXT3里填写3...最后按一下按钮,在一个标签里显示这几个数的总和?

VB按按钮之后,假如一个TEXT里填写了"1",等一小时之后,就自动弹出一个窗口?

这几个问题随便答,最好先答第二个

追问:请说明详细点,我的TEXT是TEXT1,按钮是Command17,输入字数为N小时,还有,TIMER控件的时间如何设定更长?(目前只能设定在65535)

请赐教,代码最好啦!

答案:楼上的回答连连出错

1.label1没text,只有caption

2.没有value函数,只有val函数

第三个问题

Private Sub Timer1_Timer()
Static i As Integer
If i > 59 Then MsgBox ""
End Sub

第二个问题:

如果标签是label1,大致这样:

label1.text=cstr(value(text1.text)+value(text2.text)+value(text3.text))

其中的value根据你的数值的类型,可以变为相应的函数。

第三个问题需要一个timer控件,解决。

第一个问题,初学者需要较长的时间才能掌握,建议看看书本。

窗体上加4个按纽 把后3个的Visible = False 把按纽的位置都放在一起名字也一样看上去就象一个

再加个标签 加1个文本 复制去4个文本组来 把复制的Visible = False 代码入下:

Private Sub Command1_Click()
Text1(1).Visible = True
Command1.Visible = False
Command2.Visible = True
End Sub

Private Sub Command2_Click()
Text1(2).Visible = True
Command1.Visible = False
Command2.Visible = False
Command3.Visible = True
End Sub

Private Sub Command3_Click()
Text1(3).Visible = True
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
Command4.Visible = True
End Sub

Private Sub Command4_Click()
Text1(4).Visible = True
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
Command4.Visible = True
MsgBox "窗体没位置可以增加了", 0, "提示"
Label1.Caption = "文本相加的结果为:" & Val(Text1(0)) + Val(Text1(1)) + Val(Text1(2)) + Val(Text1(3)) + Val(Text1(4))
End Sub

Private Sub Form_Load()
Label1.Caption = "文本相加的结果为:"
End Sub
文本都是text1看上去就象增加的

第二:

控件:text1,text2,text3,label1,command1

代码:

private sub command1_Click()

label1.Caption=val(text1.Text)+val(text2.Text)+val(text3.Text)

end sub

第三:

控件:text1,command1,timer1

代码

dim waitIndex as Long

private sub Form_Load()

waitIndex=0

timer1.Enabled=False

end sub

private sub command1_Click()

if val(text1.Text) >0 then

waitIndex=0

timer1.Enabled=True

end if

end sub

private sub timer1_Timer()

waitIndex=waitIndex+1

dim n as Double

n=waitIndex / 3600

if n >= val(text1.Text) then

msgbox "时间到"

end if

end sub

第一题,暂不贴代码,具体你加我,我给你详细说明,这里也有人回答到一部分就是

dim WithEvents ...

上一个:VB编程代码?
下一个:VB编程问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,