Consulting

Results 1 to 3 of 3

Thread: Textbox showing array values

  1. #1

    Textbox showing array values

    Hi guys,

    I have an array () and 8 textbox (always 8)
    what im trying to do is making
    tetxbox1 get value from array in position (1)
    tetxbox2 get value from array in position (2)
    .
    .
    .
    .
    .

    While the array are being filled.

    My code:

    Dim filepath() As String
    
    Private Sub CommandButton4_Click()
    
    Const msoFileDialogOpen = 1
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objWord = CreateObject("Word.Application")
    Set WshShell = CreateObject("WScript.Shell")
    strInitialPath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop\"
    objWord.ChangeFileOpenDirectory (strInitialPath)
    With objWord.FileDialog(msoFileDialogOpen)
    .Title = "Select the file to process"
    .AllowMultiSelect = True
    .Filters.Clear
    .Filters.Add "All Files", "*.*"
    .Filters.Add "Excel Files", "*.xls;*.xlsx"
    .Filters.Add "Text Files", "*.txt"
    .Filters.Add "Various Files", "*.xls;*.doc;*.vbs"
     If .Show = -1 Then
      
    Dim num As Integer
    On Error Resume Next
    num = UBound(filepath)
    On Error GoTo 0
    ReDim Preserve filepath(num + .SelectedItems.Count)
    
    For Each file In .SelectedItems
                Set objFile = fso.GetFile(file)
                num = num + 1
                filepath(num) = objFile
                TextBox14.Text = num & (" - Ficheiro(s) Adicionado(s)")
                
    
    Next
    
    Else
    
    End If
           
    End With
    
    End Sub
    Someone can help or give me some lights pls?

    Thanks,
    Daniel

  2. #2
    *That code is used to attach files, each file i attach(select) get one new position in filepath(). And in my form i have 8 textbox(invisible by default). What im trying to do is, when filepath(1) is filled(by the attach), textbox1 becomes visible, when filepath(2) is filled(by the attach) textbox2 becomes visible. . . . .

  3. #3
                For Each file In .SelectedItems 
                    Set objFile = fso.GetFile(file) 
                    num = num + 1 
                    filepath(num) = objFile 
                    if num < 9 then me.controls("TextBox" & num).text = filepath(num): me.controls("TextBox" & num).visible = true
                    TextBox14.Text = num & (" - Ficheiro(s) Adicionado(s)") 
                     
                     
                Next
    try adding the above line into your code, you nay need to replace the me keyword with the name of the parent of the 8 textboxes, but i am unsure where the textboxes are contained

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •