Скопируйте TextBox в пользовательскую форму - PullRequest
0 голосов
/ 05 ноября 2018

Итак, это проблема ... У меня есть пользовательская форма с несколькими текстовыми полями на одной странице. Внутри цикла мне нужно скопировать все эти текстовые поля, создать новую страницу, вставить текстовые поля и заполнить их новыми данными. Моя проблема в том, как ввести значения в эти вставленные текстовые поля?

        Do While wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column) <> ""

        currCell = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column)           
        currDlUarfcn = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 3)
        currPsc = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 4)
        currRootSeqIdx = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 5)
        currZone = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 6)
        currCellId = Right(currCell, 1)

        'Enter data in first Page
        Site.txtLteCellName = currCell
        Site.txtLteCellId = txtLteBtsId
        Site.txtLteUarfcnDl = currDlUarfcn
        Site.txtLteAzimuth = currAzimuth
        Site.txtLtePsc = currPsc
        Site.txtLteTac = currTac
        Site.txtLteRsi = currRootSeqIdx
        Site.txtLteLoCellId = currLoCellId
        Site.txtLteSector = currSector
        Site.txtLteSectorEq = currEquipmentId
        Site.txtLtePower = "40W"
        Site.txtLteCabinet = currCabinet
        Site.txtLteSubrack = currSubrack
        Site.txtLteSlot = currSlot

        'Create new page, copy and paste textBoxes
        Dim l As Double, r As Double
        Dim ctl As Control

        MultiPage4.Pages.Add

        MultiPage4.Pages(0).Controls.Copy
        MultiPage4.Pages(1).Paste

         For Each ctl In MultiPage4.Pages(0).Controls
            If TypeOf ctl Is MSForms.Frame Then
                l = ctl.Left
                r = ctl.Top
                Exit For
            End If
        Next

        For Each ctl In MultiPage4.Pages(1).Controls
            If TypeOf ctl Is MSForms.Frame Then
                ctl.Left = l
                ctl.Top = r
                Exit For
            End If
        Next

        lin1 = lin1 + 1

    Loop

Изображение пользовательской формы

1 Ответ

0 голосов
/ 05 ноября 2018

Для экспериментальных целей я использую следующую ссылку:

UserForm: frmTest TextBox: txtTest

Попытка:

    With frmTest '<= Refer to the userform with it s name
        .txtTest.Value = "Finished" '<= Refer to text box with it s name & assign value
    End With
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...