vb编程里的一个小问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 00:52:26
窗体上有text1 text2 和command1
设计要求;若将光标定位在text1 单击comman1 后 command1 的caption将赋给text1.text; 若将光标定位在text2 单击comman1 后 command1 的caption将赋给text2.text 该怎样编程 要用到setfocus或是gotfocus吗

给你一个思路
在text1或者text2失去焦点的时候会触发一个事件,这个时候设置一个变量a=1或2,然后按command1_click()里面判断a的值来赋值

按你说的要用 gotfocus 按楼上说的可以啊
text2失去焦点时:
Dim a as string
a="a"
点击按钮时:
if a = "a" then
text2.text=command1.caption
好像要有全局变量?