Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vb question

  • 07-02-2008 6:43pm
    #1
    Closed Accounts Posts: 114 ✭✭


    anyone know how to read the contents of an xls file into an array in a vb6 application? Also how do you do a file input box where the user can browse their computer to find the file they wish to insert into the form?


Comments

  • Closed Accounts Posts: 164 ✭✭ob


    I did something similar in vba, but you can probably adapt it. What this code does is populate a 2-dimensional array with the contents of the worksheet.


    Public Sub ReadIntoArray
    Dim arrContents() As String
    Worksheets("Sheet1").Activate
    Dim ArrayColumns, ArrayRows, i, j As Integer
    ArrayRows = Cells.SpecialCells(xlCellTypeLastCell).Row
    ArrayColumns = Cells(1, Columns.Count).End(xlToLeft).Column
    ReDim arrContents(ArrayRows - 1, ArrayColumns - 1)
    For i = LBound(arrContents, 1) To UBound(arrContents, 1)
    For j = LBound(arrContents, 2) To UBound(arrContents, 2)
    arrContents(i, j) = Range(Cells(i + 1, j + 1), Cells(i + 1, j + 1))
    Next j
    Next i
    End Sub


Advertisement