none
How do I use an Excel file as a data source for a Visual Studio Express 2012 desktop application? RRS feed

  • Question

  • Hi guys and girls,

    I am new to programming!

    I wrote a demo version of what I am creating in Excel forms, however I am now recreating it in Visual Studio.

    The application I am creating needs to be able to read table data from an Excel file to populate objects such as; ComboBox's and also allow lookup/match functions (referencing back to the Excel doc).

    Further to this I will also need the app to be able to take the information the user has selected and add it to a separate Excel file/tab.

    Below is a sample of the code I put together in Excel forms:

            '        Dim matchTest As Object
    
            '        matchTest = Microsoft.
            '        matchTest = Application.Match(ComboBox1.Value, Sheets("Sheet_Working").Range("B1:B10000"), 0)
    
            '        If Not IsError(matchTest) Then
            '            TextBox2.Value = Application.WorksheetFunction.Index(Sheets("Sheet_Working").Range("C1:C10000"), _
            '            Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Sheet_Working").Range("B1:B10000"), 0), 1)
            '            TextBox1.Value = Application.WorksheetFunction.Index(Sheets("Sheet_Working").Range("A1:A1000"), _
            '            Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Sheet_Working").Range("B1:B10000"), 0), 1)
            '        Else
            '            TextBox2 = ""
            '            TextBox1 = ""
            '        End If
    
            '        Dim matchTest2 As Object
            '        matchTest2 = Application.Match(ComboBox3.Value, Sheets("Sheet_Working").Range("F1:F10000"), 0)
            '        Dim TestSup As String
            '        If ComboBox3.Value <> "" Then
            '            TestSup = Application.WorksheetFunction.Index(Sheets("Sheet_Working").Range("E1:E1000"), _
            '            Application.WorksheetFunction.Match(ComboBox3.Value, Sheets("Sheet_Working").Range("F1:F10000"), 0), 1)
            '        End If
    
            '        If Len(TextBox1.Value) = 14 Then TextBox1.Value = Left$(TextBox1.Value, Len(TextBox1.Value) - 4)
    
            '        If Len(TextBox1.Value) >= 8 Then
            '            If Mid(TextBox1.Value, 9, 1) = "S" Then TextBox1.Value = Left$(TextBox1.Value, Len(TextBox1.Value) - 1)
            '            If Mid(TextBox1.Value, 9, 1) = "D" Then TextBox1.Value = Left$(TextBox1.Value, Len(TextBox1.Value) - 1)
            '            If ComboBox2.Value = "Sign-Off" Then TextBox1.Value = TextBox1.Value & "S" & "_" & TestSup
            '            If ComboBox2.Value = "Development" Then TextBox1.Value = TextBox1.Value & "D" & "_" & TestSup
            '        End If
            'End With

    Any help will be greatly appreciated.

    Many thanks,

    Calum

    Wednesday, March 21, 2018 9:31 AM

All replies