Portée des variables dans une classe
Bonjour à tous,
Je voudrais savoir quelle est la porté de ma variable, voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Partial Class SearchByBatch
Inherits System.Web.UI.Page
Private _batchValues As BatchValues = New BatchValues
Protected Sub ButtonSearch_Click() Handles ButtonSearch.Click
If TextBoxSearch.ToString <> "" Then
Try
_batchValues.gridViewValues(Me.TextBoxSearch.Text.ToString, Me.ph)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
For Each element In _batchValues.listCheckBox
MsgBox("test")
'J'ai plusieurs box qui s'affichent
Next
End Sub
Protected Sub ButtonExportExcel_Clik() Handles ButtonExport.Click
For Each element In _batchValues.listCheckBox
MsgBox("test")
'Et là rien ne s'affiche ..
Next
End Sub
End Class |
Pourquoi est-ce que j'ai des "test" qui s'affichent dans ma première méthode alors que dans la deuxième non ?
J'ai pourtant déclarée la variable avant mes méthodes, elle devrait être "globale" au deux méthodes ?
Merci d'avance :ccool: