以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  窗口数据合计  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=119185)

--  作者:ZJZK2018
--  发布时间:2018/5/19 13:35:00
--  窗口数据合计
老师如何达到下面的需求:

图片点击可在新窗口打开查看此主题相关图片如下:e3}76b_z2klx7$q4h)99.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2018/5/19 14:21:00
--  
在每个textbox的textchanged写代码

dim txt as string = e.form.controls(textbox1).text
dim sum as integer
dim str as string
if txt > "" then
str = str & "木工:" & txt & "人,"
sum+= val(txt)
endif
txt  = e.form.controls(textbox2).text
dim str as string
if txt > "" then
str = str & "泥工:" & txt & "人,"
sum+= val(txt)
endif
……其它自己补齐
e.form.controls(textbox显示).text = str & "共计:" & sum & “人”

--  作者:ZJZK2018
--  发布时间:2018/5/19 17:17:00
--  
有点蓝老师:

我的需求是:因为工种实在太多,一个一个编辑感觉太多,能否采用历遍控件的名称进行编辑,如“木工”的label的名称设为“mg_lb”,textbox的名称设为“mg_tbx”,其他类同,折腾了半天还是编不出来,只有麻烦老师了,十分感谢!!

For Each c As WinForm.Control In e.Form.Controls
    If Typeof c Is WinForm.TextBox Then \'判断控件是否是文本框
        Dim t As WinForm.TextBox = c \'使用特定类型的变量引用控件
        If t.Value > ""
            MessageBox.Show(t.name)
            \'t.Value = Nothing
        End If
    End If
    If Typeof c Is WinForm.Label Then \'判断控件是否是文本框
        Dim lb As WinForm.Label = c  \'使用特定类型的变量引用控件
        If lb.Value > ""
            MessageBox.Show(lb.name)
            \'t.Value = Nothing
        End If
    End If
Next


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20180519171746.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2018/5/19 17:30:00
--  
Dim sum As Integer
Dim str As String

For Each c As WinForm.Control In e.Form.Controls
    If Typeof c Is WinForm.TextBox Then \'判断控件是否是文本框
        Dim t As WinForm.TextBox = c \'使用特定类型的变量引用控件
        If t.Name.EndsWith("_tbx") AndAlso t.Text > ""
            str = str & e.Form.controls(t.Name.Split("_")(0) & "_lb").text & t.Text & "人,"
            sum+= val(t.Text)
        End If
    End If
Next
msgbox(str & "共计:" & sum & "人")
[此贴子已经被作者于2018/5/19 17:31:23编辑过]

--  作者:ZJZK2018
--  发布时间:2018/5/19 17:43:00
--  
有点蓝老师出错了:


图片点击可在新窗口打开查看此主题相关图片如下:77777777.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2018/5/19 17:49:00
--  
代码测试没有问题,请检查其它代码
--  作者:ZJZK2018
--  发布时间:2018/5/19 17:52:00
--  
谢谢有点蓝老师,我搞错了
--  作者:ZJZK2018
--  发布时间:2018/5/24 20:43:00
--  
老师你好:

3楼是根据文本框内容生成一个字符串,我现在想双击这个字符串,把这字符串相关的数字值返回到窗口界面中相应的textbox中去,如何操作?谢谢

Dim sum As Integer
Dim str As String
Dim st As String = "施工人员:混凝土工:3人,钢筋工:1人,木工:2人,共计:6人"
For Each c As WinForm.Control In e.Form.Controls
    If Typeof c Is WinForm.label Then \'判断控件是否是文本框
        Dim t As WinForm.label = c \'使用特定类型的变量引用控件
        If st.Contains(t.text) Then
            
            MessageBox.Show(t.text)
        End If
    End If
Next
[此贴子已经被作者于2018/5/24 20:43:34编辑过]

--  作者:有点甜
--  发布时间:2018/5/24 22:20:00
--  

Dim sum As Integer
Dim str As String
Dim st As String = "施工人员:混凝土工:3人,钢筋工:1人,木工:2人,共计:6人"
st = st.Replace("施工人员:", "")
Dim ary As String() = st.split(",")
For Each c As WinForm.Control In e.Form.Controls
    If Typeof c Is WinForm.label Then \'判断控件是否是文本框
        Dim t As WinForm.label = c \'使用特定类型的变量引用控件
        For Each s As String In ary
            If s.contains(t.text) Then
                Dim lbname As String = t.name
                e.form.controls(lbname.replace("_lb", "_tbx")).text = s.split(":")(1)
            End If
        Next
    End If
Next

--  作者:ZJZK2018
--  发布时间:2018/5/25 12:02:00
--  
老师你好:
下面这段代码如何修改?谢谢
Dim dics As new SortedDictionary(Of Integer, object)
For Each c As object In e.form.controls
    dics.Add(c.tabindex, c)
Next
For Each key As Integer In dics.keys

   If Typeof cc Is WinForm.ComboBox Then \'判断控件是否是文本框
       Dim t As WinForm.ComboBox = cc \'使用特定类型的变量引用控件
        If t.Name.EndsWith("_tbx") AndAlso t.Text > ""
            str = str & e.Form.controls(t.Name.Split("_")(0) & "_lb").text & t.Text & ","
            \'sum += val(t.Text)
        End If
    End If
  
Next
msgbox(str)