Fai queste modifiche:
codice:
Public Class Profilo
Private myusername As String
Private myid As Integer
Public Property idutente() As Integer
Get
Return myid
End Get
Set(ByVal value As Integer)
myid = value
End Set
End Property
Public Property UserName() As String
Get
Return myusername
End Get
Set(ByVal value As String)
myusername = value
End Set
End Property
End Class
codice:
Dim Profilo(10) As Profilo
For i As Integer = 0 To 10
Profilo(i) = New Profilo
Profilo(i).idutente = i
Profilo(i).UserName = "User" & i.ToString
Next
Dim profiloSelezionato As Integer = 1
Dim userSelezionato As String = Profilo(profiloSelezionato).UserName
idutente diventa un intero, inutile scomodare una variabile stringa!
Oppure molto più elegante:
codice:
Public Class Profilo
Private myusername() As String
Private myid() As Integer
Sub New(ByVal numeroutenti As Integer)
ReDim myusername(numeroutenti)
ReDim myid(numeroutenti)
End Sub
Public Property idutente(ByVal i As Integer) As Integer
Get
Return myid(i)
End Get
Set(ByVal value As Integer)
myid(i) = value
End Set
End Property
Public Property UserName(ByVal i As Integer) As String
Get
Return myusername(i)
End Get
Set(ByVal value As String)
myusername(i) = value
End Set
End Property
End Class
e..
codice:
Try
Dim Profilo As New Profilo(10)
For i As Integer = 0 To 10
Profilo.idutente(i) = i
Profilo.UserName(i) = "User" & i.ToString
Next
Dim profiloSelezionato As Integer = 1
Dim userSelezionato As String = Profilo.UserName(profiloSelezionato)
Catch ex As Exception
End Try