标题:变量值与text控件值改变问题
只看楼主
建生65
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2018-5-10
结帖率:100%
 问题点数:0 回复次数:4 
变量值与text控件值改变问题
    在窗口初始化事件的时候,用代码给text控件赋值,然后在将控件的值赋值给变量。现在想实现在程序运行的过程中,当控件的值改变时,变量的值跟随改变,应该怎么做呀?知道的朋友麻烦指导下,谢谢
    Form2.Text1.Text = 6.2
    Form2.Text2.Text = 4.145
    Form2.Text3.Text = 2.6
    Form2.Text4.Text = 0.6
    Form2.Text5.Text = 0.1333
    Form2.Text6.Text = 0.3
    Form2.Text7.Text = 0.25
    Form2.Text8.Text = 0.75
    Form2.Text9.Text = 0.7
    Form2.Text10.Text = 0.508
    Form2.Text11.Text = 0.0255
    Form2.Text12.Text = 33
    Form2.Text13.Text = 1800
    Form2.Text14.Text = 0.039
    Form2.Text15.Text = 36
    Form2.Text16.Text = 530
    Form2.Text17.Text = 2
    Form2.Text18.Text = (90 - 82.433) / 57.3
    Form2.Text19.Text = 13.6
    Form2.Text20.Text = 0.2
    Form2.Text21.Text = 0.85
    Form2.Text22.Text = 0.85

    Dh = Val(Form2.Text1.Text): hg = Val(Form2.Text2.Text)
    L0 = Val(Form2.Text3.Text): e = Val(Form2.Text4.Text)
    w = Val(Form2.Text5.Text): u = Val(Form2.Text6.Text)
    h1 = Val(Form2.Text7.Text): Df = Val(Form2.Text8.Text)
    K1 = Val(Form2.Text9.Text): K2 = Val(Form2.Text10.Text)
    dk = Val(Form2.Text11.Text): angleK = Val(Form2.Text12.Text)
    densityK = Val(Form2.Text13.Text): dj = Val(Form2.Text14.Text)
    angleJ = Val(Form2.Text15.Text): densityJ = Val(Form2.Text16.Text)
    Hh = Val(Form2.Text17.Text): angleL = Val(Form2.Text18.Text)
    HS = Val(Form2.Text19.Text): K3 = Val(Form2.Text20.Text)
    K4 = Val(Form2.Text21.Text): K5 = Val(Form2.Text22.Text)
   
搜索更多相关主题的帖子: 变量 text 控件 改变 Text1 
2018-06-21 14:08
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
得分:0 
事件

无知
2018-06-21 23:54
wds1
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:49
帖 子:393
专家分:2025
注 册:2016-3-10
得分:0 
Private Sub Text1_Change()
'你的赋值语句
end sub

如果text用数组,就可以一次事件完成多个赋值



[此贴子已经被作者于2018-6-22 11:41编辑过]

2018-06-22 11:39
ZHRXJR
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:125
帖 子:1034
专家分:5519
注 册:2016-5-10
得分:0 
这个使用动态控件程序非常简单,而且程序量比你现在的还要少,设计时仅仅放置一个Text1(0)控件就可以了。
如果你需要可以帮您做一个这样的动态程序。

请不要选我!!!
2018-06-23 12:15
wufuzhang
Rank: 9Rank: 9Rank: 9
来 自:广州
等 级:贵宾
威 望:21
帖 子:206
专家分:1346
注 册:2017-8-9
得分:0 
回复 楼主 建生65
程序代码:
Private Sub Form_Load()
    Form2.Text1.Text = 6.2
    Form2.Text2.Text = 4.145
    Form2.Text3.Text = 2.6
    Form2.Text4.Text = 0.6
    Form2.Text5.Text = 0.1333
    Form2.Text6.Text = 0.3
    Form2.Text7.Text = 0.25
    Form2.Text8.Text = 0.75
    Form2.Text9.Text = 0.7
    Form2.Text10.Text = 0.508
    Form2.Text11.Text = 0.0255
    Form2.Text12.Text = 33
    Form2.Text13.Text = 1800
    Form2.Text14.Text = 0.039
    Form2.Text15.Text = 36
    Form2.Text16.Text = 530
    Form2.Text17.Text = 2
    Form2.Text18.Text = (90 - 82.433) / 57.3
    Form2.Text19.Text = 13.6
    Form2.Text20.Text = 0.2
    Form2.Text21.Text = 0.85
    Form2.Text22.Text = 0.85

    Dh = Val(Form2.Text1.Text): hg = Val(Form2.Text2.Text)
    L0 = Val(Form2.Text3.Text): e = Val(Form2.Text4.Text)
    w = Val(Form2.Text5.Text): u = Val(Form2.Text6.Text)
    h1 = Val(Form2.Text7.Text): Df = Val(Form2.Text8.Text)
    K1 = Val(Form2.Text9.Text): K2 = Val(Form2.Text10.Text)
    dk = Val(Form2.Text11.Text): angleK = Val(Form2.Text12.Text)
    densityK = Val(Form2.Text13.Text): dj = Val(Form2.Text14.Text)
    angleJ = Val(Form2.Text15.Text): densityJ = Val(Form2.Text16.Text)
    Hh = Val(Form2.Text17.Text): angleL = Val(Form2.Text18.Text)
    HS = Val(Form2.Text19.Text): K3 = Val(Form2.Text20.Text)
    K4 = Val(Form2.Text21.Text): K5 = Val(Form2.Text22.Text)
    
    
End Sub

Private Sub Text1_Change()
    Label1.Caption = "Dh=" & Text1.Text
End Sub

Private Sub Text2_Change()
    Label2.Caption = "hg=" & Text2.Text
End Sub

Private Sub Text3_Change()
    Label3.Caption = "L0=" & Text3.Text
End Sub

Private Sub Text4_Change()
    Label4.Caption = "e=" & Text4.Text
End Sub

Private Sub Text5_Change()
    Label5.Caption = "w=" & Text5.Text
End Sub

Private Sub Text6_Change()
    Label6.Caption = "u=" & Text6.Text
End Sub

Private Sub Text7_Change()
    Label7.Caption = "h1=" & Text7.Text
End Sub

Private Sub Text8_Change()
    Label8.Caption = "Df=" & Text8.Text
End Sub

Private Sub Text9_Change()
    Label9.Caption = "K1=" & Text9.Text
End Sub

Private Sub Text10_Change()
    Label10.Caption = "K2=" & Text10.Text
End Sub

Private Sub Text11_Change()
    Label11.Caption = "dk=" & Text11.Text
End Sub

Private Sub Text12_Change()
    Label12.Caption = "angleK=" & Text12.Text
End Sub

Private Sub Text13_Change()
    Label13.Caption = "densityK=" & Text13.Text
End Sub

Private Sub Text14_Change()
    Label14.Caption = "dj=" & Text14.Text
End Sub

Private Sub Text15_Change()
    Label15.Caption = "angleJ=" & Text15.Text
End Sub

Private Sub Text16_Change()
    Label16.Caption = "densityJ=" & Text16.Text
End Sub

Private Sub Text17_Change()
    Label17.Caption = "Hh=" & Text17.Text
End Sub

Private Sub Text18_Change()
    Label18.Caption = "angleL=" & Text18.Text
End Sub

Private Sub Text19_Change()
    Label19.Caption = "HS=" & Text19.Text
End Sub

Private Sub Text20_Change()
    Label20.Caption = "K3=" & Text20.Text
End Sub

Private Sub Text21_Change()
    Label21.Caption = "K4=" & Text21.Text
End Sub

Private Sub Text22_Change()
    Label22.Caption = "K5=" & Text22.Text
End Sub


[此贴子已经被作者于2018-6-23 14:31编辑过]


不经历千百遍的调试,怎能体会成功时那一刹那的喜悦。
2018-06-23 14:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-488056-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.322871 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved