retrieving data from multiple textboxes created during runtime in an Excel userform using vba

耗尽温柔 提交于 2019-12-25 09:44:01

问题


Okay...so I got some great help resolving my issue with adding multiple labels and textboxes to an Excel userform during runtime using vba. Now, the issue is I'm trying to retrieve data from those dynamically created textboxes. It's not that I can't get the data, it's that I can't pull it out of the form and use it once the form is closed.

I used the following code sets for retrieving data from a single option textbox and it works perfectly:

Private Sub SOSubmitButton_Click()
    FLNAmt = SingleOptionForm.SOBox
    Unload SingleOptionForm
End Sub

and

SingleOptionForm.Show
SingleOptionForm.Hide

When I use FLNAmt shortly after hiding the form, there's data in the variable. However, using some of the much similar coding:

Private Sub AsgnFLNButton_Click()
    Dim MultFLNAmt As String
    Dim i As Integer
    i = 1
    If i = 1 Then
        MultFLNAmt = MultipleOptionForm.Controls("Textbox" & i)
    Else
        MultFLNAmt = MultFLNAmt & "," & MultipleOptionForm.Controls("Textbox" & i)
    End If

    Unload MultipleOptionForm
End Sub

and

MultipleOptionForm.Show    
MultipleOptionForm.Hide

MsgBox MultFLNAmt

When the MsgBox appears, MultFLNAmt is blank. Is there something different I need to do when gathering data from dynamically created textboxes and using it after the form closes than I do when using a textbox already hard coded into the form?

来源:https://stackoverflow.com/questions/46117064/retrieving-data-from-multiple-textboxes-created-during-runtime-in-an-excel-userf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!