vb如何获得TEXT中的内容

来源:百度知道 编辑:UC知道 时间:2024/05/17 18:36:10
Private Sub Command1_Click()
Dim hello As Variant
upbound = InputBox("enter avalue", "number", "")
lowbound = InputBox("enter avalue", "number", "4")
upbound = Val(upbound)
lowbound = Val(lowbound)
ReDim hello(1 To upbound, 1 To lowbound)
hello(1, 1) = zhangdegong
hello(1, 2) = man
hello(1, 3) = 24
hello(1, 4) = university
hello(1, 5) = hebei
hello(2, 1) = lidesheng
hello(2, 2) = man
hello(2, 3) = 30
hello(2, 4) = university
hello(2, 5) = beijin
hello(3, 1) = wanli
hello(3, 2) = woman
hello(3, 3) = 25
hello(3, 4) = "graduate student"
hello(3, 5) = hebei
If Text1.Text = zhangdegong Then
Text2.Text = hello(1, 1)
Text3.Text = hello(1, 2)
Text4.Text = hello(1, 3)
Text5.Text = hello(1, 4)
Else
If Text1.Text = lidesheng Then
Text2.Text = hello(2, 1)
Text3.Text = hello(2, 2)

vb获得TEXT中的内容的方法:
1.Text = zhangdegong Then
1、Dim hello As Variant 定
2、IF语句必须清楚:
IF 条件 THEN
........
ELSE
........
END IF
3、hello(1, 1) = zhangdegong 。
4、 同样If Text1.Text = zhangdegong Then 中的zhangdegong。

你的程序中很多问题我不清楚,比如是变量?变量从那里来?zhangdegong 、 man 、university 、hebei 、lidesheng 、man 、university 、beijin 、wanli 、woman 、hebei等等到底是什么? If Text1.Text = zhangdegong Then 等你准备是判断什么?因此无法为你修改!

问题很多:
1、Dim hello As Variant 定义了一个变量,但后面用的是数组:hello(1, 1)等等,这就不会通过;
2、IF语句必须清楚:
IF 条件 THEN 必须的!
........
ELSE 可有可无
........
END IF 必须的!
3、hello(1, 1) = zhangdegong 的赋值语句中,不知zhangdegong是不是变量,如果是变量是没有问题的,如果是字符串,就是问题。
4、 同样If Text1.Text = zhangdegong Then 中的zhangdegong是变量吗?但Text1.Text是一个具体的字符串内容,不会是变量的。
等等等等,你再仔细检查吧!

字符串要加引号(""),例如:Text1.Text = "zhangdegong",你的字符串都没加""

还有
If Text1.Text = "zhangdegon