solartorch
Newcomer
Hi guys,
I used to use VB6 to program. Now I'm trying to upgrade to VB.NET.
My idea of this small program is this
1, read data from Excel
2, draw rectangle using the data
Follows my code
Could anyone tell me what's the modification I should carry out? I'm using Visual Studio 2005 Professional Edition now
Any help will be very appriciated.
I used to use VB6 to program. Now I'm trying to upgrade to VB.NET.
My idea of this small program is this
1, read data from Excel
2, draw rectangle using the data
Follows my code
Visual Basic:
Option Explicit
Dim X1 As Integer
Dim X2 As Integer
Dim Y1 As Integer
Dim Y2 As Integer
Private Sub Form_Load()
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Set oXLApp = New Excel.Application 'Create a new instance of Excel
Set oXLBook = oXLApp.Workbooks.Open("D:\New Folder\Book1") 'Open an existing workbook
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet
Dim my_variable As String
my_variable = "hello"
oXLSheet.Cells(2, 1).Value = my_variable
X1 = oXLSheet.Cells(1, 1).Value
Y1 = oXLSheet.Cells(1, 2).Value
X2 = oXLSheet.Cells(1, 3).Value
Y2 = oXLSheet.Cells(1, 4).Value
oXLApp.Visible = True 'Show it to the user
Set oXLSheet = Nothing 'Disconnect from all Excel objects (let the user take over)
Set oXLBook = Nothing
Set oXLApp = Nothing
End Sub
Private Sub Form_Resize()
Me.Scale (0, 0)-(200, 200)
Me.Cls
Me.Line (X1, Y1)-(X2, Y2), vbYellow, BF
Me.CurrentX = X1
Me.CurrentY = Y1
Me.Print "CW1"
End Sub
Could anyone tell me what's the modification I should carry out? I'm using Visual Studio 2005 Professional Edition now
Any help will be very appriciated.