samandrew
asked on
CREATE AN ARRAY FOR EXISTING CODE
hI
I have the following code and would like to use this in an array of 6 txtboxs would anyone be able to give me some example code ?
Private Sub txtMorActS_Change()
If IsNumeric(txtMorEst(0).Tex t) And IsNumeric(txtMorActS.Text) Then
If CDbl(txtMorActS.Text) < 0.00001 Then
txtPercent.Text = "0"
Else
txtPercent.Text = Format(Val(txtMorActS.Text ) - Val(txtMorEst(0).Text) / Val(txtMorActS.Text) * 100, "#0") & "%"
End If
End If
txtMorMixS.Text = Format$(txtMorEst(0).Text * 16 * 6 / 1925, "#0.0")
End Sub
I have the following code and would like to use this in an array of 6 txtboxs would anyone be able to give me some example code ?
Private Sub txtMorActS_Change()
If IsNumeric(txtMorEst(0).Tex
If CDbl(txtMorActS.Text) < 0.00001 Then
txtPercent.Text = "0"
Else
txtPercent.Text = Format(Val(txtMorActS.Text
End If
End If
txtMorMixS.Text = Format$(txtMorEst(0).Text * 16 * 6 / 1925, "#0.0")
End Sub
can you explain further what you wish to accomplish? in your code, only txtMorEst is an array.
ASKER
hI
I want to make txtMorActS.Text an array and execute the code as above.
Many Thanks
Andy
I want to make txtMorActS.Text an array and execute the code as above.
Many Thanks
Andy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or like this (now that I've seen your last comment)
Private Sub txtMorActS_Change(Index As Integer)
If IsNumeric(txtMorEst(Index).Text) And IsNumeric(txtMorActS.Text) Then
If CDbl(txtMorActS.Text) < 0.00001 Then
txtPercent.Text = "0"
Else
txtPercent.Text = Format(Val(txtMorActS.Text) - Val(txtMorEst(Index).Text) / Val(txtMorActS.Text) * 100, "#0") & "%"
End If
End If
txtMorMixS.Text = Format$(txtMorEst(Index).Text * 16 * 6 / 1925, "#0.0")
End Sub
Oops. txtMorActS needs indexing, too
Private Sub txtMorActS_Change(Index As Integer)
If IsNumeric(txtMorEst(Index).Text) And IsNumeric(txtMorActS.Text) Then
If CDbl(txtMorActS(Index).Text) < 0.00001 Then
txtPercent.Text = "0"
Else
txtPercent.Text = Format(Val(txtMorActS(Index).Text) - Val(txtMorEst(Index).Text) / Val(txtMorActS(Index).Text) * 100, "#0") & "%"
End If
End If
txtMorMixS.Text = Format$(txtMorEst(Index).Text * 16 * 6 / 1925, "#0.0")
End Sub
ASKER
Many Thanks
Andy
Andy