Option Explicit On Imports Microsoft.Office.Interop.Excel Public Class MainForm Dim Excelobject As Object Dim ExcelBook As Object Dim ExcelSheet As Object Dim xlsh As Object Dim CopyCell As String Public Function GetExcellFilePath() As String GetExcellFilePath = "C:\Data\ItemBase.xlsx" End Function Public Sub OpenExcellDocument() Excelobject = GetObject(GetExcellFilePath) xlsh = Excelobject.ActiveSheet If Excelobject Is Nothing Then MsgBox("Could not Open ItemBase.xlsx") End If End Sub Public Sub Weapons(ByVal Row, ByVal Column) OpenExcellDocument() MsgBox(Row & Column) Do While (xlsh.Cells(Row, Column)) CopyCell = xlsh.Cells(Row, Column).Value.ToString() Me.ComboBoxWeapons.Items.Add(CopyCell) Row = Val(Row + 1) Loop End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button1.Click Weapons(3, 1) End Sub End Class
xlsh.Cells(Row, Column)
Boolean
foreach
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)