changing value in excel to be read in vb.net

chinrose

Member
Joined
Jul 13, 2011
Messages
15
Location
Philippines
Programming Experience
Beginner
hi guys,

i have a new problem, i was trying to create a vb.net textbox that will read the cell (1,1) of the excel once i press button1,but this cell changed from time to time, and i like to see the new value in my textbox in vb. i found something but i have to save the excel first then get the new value, but this create a bug in my program.
hope you can help me thanks.
 
Asssign the sheet to a WithEvents variable and handle the Change event, example:
Private WithEvents sheet As Excel.Worksheet

Private Sub sheet_Change(Target As Microsoft.Office.Interop.Excel.Range) Handles sheet.Change
    If Target.Address = "$A$1" Then
        Me.Invoke(Sub(text As String) Me.CellTextBox.Text = text, Target.Value.ToString)
    End If
End Sub
 
Me.Invoke(Sub(text As String) Me.CellTextBox.Text = text, Target.Value.ToString)

hi jonh,

i'm having a problem in this part, the sub create a error, how can i fix this, thanks
 
i'm having a problem in this part, the sub create a error, how can i fix this, thanks
Your profile is .Net 4.0, if that is not correct you can download VB 2010 here: Visual Basic 2010 Express | Microsoft Visual Studio

The alternative for the inline sub method for older VB is to create a named Sub method and use AddressOf operator to point to that.
 
Back
Top