L
LuigiB
Guest
perche è 13 se la stringa ha 12 caratteri ? s.Length da 12 , lo 0 non lo contiamo e non lo usiamo
Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature may not be available in some browsers.
Function Stringa01ToArrayB(s As String) As Boolean()
Dim str As String
Dim aB() As Boolean
ReDim aB(s.Length)
For r As Integer = 0 To s.Length - 1
str = s.Substring(r, 1)
If str = "1" Then
aB(r + 1) = True
Else
aB(r + 1) = False
End If
Next
Return aB
End Function
Aaaaaaaaaaaaaaaaah ecco perché ...appena possibile effettuo rettifica e posto progettoio dicevo cosi
Codice:Function Stringa01ToArrayB(s As String) As Boolean() Dim str As String Dim aB() As Boolean ReDim aB(s.Length) For r As Integer = 0 To s.Length - 1 str = s.Substring(r, 1) If str = "1" Then aB(r + 1) = True Else aB(r + 1) = False End If Next Return aB End Function
Esatto per quello avevo messo il - 1 ... comunque ancora non ho postato nulla perchè nonostante la modifica apportata continua a darmi errore con valore 13Redim ab(s.length) può essere che così la matrice contenga 13 elementi.
Per via dello zero.
Cmq bravissimo edo.
Public Class clsChekBoxModificata
Inherits CheckBox ' con questa istruzione ereditiamo dalla chekbox
' qui gestiamo le proprieta per memorizzare i colori normali e selezionati
Private mBackColorNormale As Color = SystemColors.Control
Private mBackColorSelected As Color = Color.Red
Private mForeColorNormale As Color = SystemColors.WindowText
Private mForeColorSelected As Color = Color.White
Public Property BackColorNormale As Color
Get
Return mBackColorNormale
End Get
Set(value As Color)
mBackColorNormale = value
End Set
End Property
Public Property BackColorSelected As Color
Get
Return mBackColorSelected
End Get
Set(value As Color)
mBackColorSelected = value
End Set
End Property
Public Property ForeColorNormale As Color
Get
Return mForeColorNormale
End Get
Set(value As Color)
mForeColorNormale = value
End Set
End Property
Public Property ForeColorSelected As Color
Get
Return mForeColorSelected
End Get
Set(value As Color)
mForeColorSelected = value
End Set
End Property
' qui andiamo a sovrascrivere l'evento della classe di base per poter gestire il colore
Protected Overrides Sub OnCheckedChanged(e As EventArgs)
MyBase.OnCheckedChanged(e)
If MyBase.Checked Then
Me.BackColor = mBackColorSelected
Me.ForeColor = mForeColorSelected
Else
Me.BackColor = mBackColorNormale
Me.ForeColor = mForeColorNormale
End If
End Sub
End Class
Public Class cltSelRuote
Private Check() As CheckBox
Private Const nCheck As Integer = 12
Private mBackColorNormale As Color = SystemColors.Control
Private mBackColorSelected As Color = Color.Red
Private mForeColorNormale As Color = SystemColors.WindowText
Private mForeColorSelected As Color = Color.White
Public Property BackColorNormale As Color
Get
Return mBackColorNormale
End Get
Set(value As Color)
mBackColorNormale = value
End Set
End Property
Public Property BackColorSelected As Color
Get
Return mBackColorSelected
End Get
Set(value As Color)
mBackColorSelected = value
End Set
End Property
Public Property ForeColorNormale As Color
Get
Return mForeColorNormale
End Get
Set(value As Color)
mForeColorNormale = value
End Set
End Property
Public Property ForeColorSelected As Color
Get
Return mForeColorSelected
End Get
Set(value As Color)
mForeColorSelected = value
End Set
End Property
Private Sub cltSelRuote_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadCampi()
End Sub
Sub LoadCampi()
Dim i As Integer
Dim nX As Integer, nY As Integer
Dim nHTxt As Integer = 15, nWTxt As Integer = 25
Dim Altezza As Integer = 21, Larghezza As Integer = 35
Dim nLeft As Integer = 10
ReDim Check(nCheck)
nX = 0
nY = 0
For r As Integer = 1 To nCheck
i += 1
Check(i) = New clsChekBoxModificata
With Check(i)
.AutoSize = False
.Checked = False
.Left = nX
.Top = nY
.Width = Larghezza
.Height = Altezza
.TextAlign = ContentAlignment.MiddleCenter
.Appearance = Appearance.Button
.Text = NomiRuote(i).NomeAbbreviato
Me.Controls.Add(Check(i))
AddHandler Check(i).CheckStateChanged, AddressOf Gestione_CheckstateChanged
.Visible = True
End With
nX = nX + Larghezza
Next
End Sub
Private Sub Gestione_CheckstateChanged(sender As Object, e As EventArgs)
End Sub
Function GetRuoteSelezionate(ByRef aRetRuote() As Integer) As Integer
Dim i As Integer
ReDim aRetRuote(nCheck) ' dimensiono al massimo possibile
For x As Integer = 1 To nCheck
If Check(x).Checked = True Then
i += 1
aRetRuote(i) = x ' giusto
End If
Next
ReDim Preserve aRetRuote(i) ' ridimensiono al numero di ruote trovate
Return i
End Function
Function GetRuoteSelezionate(ByRef aRetRuote() As Boolean) As Integer
Dim i As Integer
ReDim aRetRuote(nCheck) ' dimensiono al massimo possibile
For x As Integer = 1 To nCheck
If Check(x).Checked = True Then
i += 1
aRetRuote(x) = True
End If
Next
Return i
End Function
Sub SetRuoteSelezionate(aRuote() As Integer)
For x As Integer = 1 To UBound(aRuote)
Check(aRuote(x)).Checked = True
Next
End Sub
Sub SetRuoteSelezionate(aRuote() As Boolean)
For x As Integer = 1 To UBound(aRuote)
Check(x).Checked = aRuote(x)
Next
End Sub
End Class
Dim aRuote() = {"", "ba", "ca", "Fi", "Ge", "Mi", "Na", "Pa", "Rm", "To", "Ve", "Nz", "Tt"}
Me.Controls.clear
For r As Integer = 1 To nCheck
Check(r) = New clsChekBoxModificata
With Check(r)
.AutoSize = False
.Checked = False
.Left = nX
.Top = nY
.Width = Larghezza
.Height = Altezza
.TextAlign = ContentAlignment.MiddleCenter
.Appearance = Appearance.Button
.Text = aRuote(r)
Me.Controls.Add(Check(r))
AddHandler Check(r).CheckStateChanged, AddressOf Gestione_CheckstateChanged
.Visible = True
End With
nX = nX + Larghezza
Next