i have :
vb code:
Private Sub Calculation()
Dim txt1 As Decimal
txt1 = (CS_Incoms_done.Text / CS_Incoms_target.Text) * 100
CS_Incom_Result.Text = "%" + FormatNumber(txt, 2, TriState.False)
Dim txt2 As Decimal
txt2 = (CS_GovernmentService_done.Text / CS_GovernmentService_target.Text) * 100
CS_GovernmentService_Result.Text = "%" + FormatNumber(txt2, 2, TriState.False)
Dim txt3 As Decimal
txt3 = (CS_RentBox_done.Text / CS_RentBox_target.Text) * 100
CS_RentBox_Result.Text = "%" + FormatNumber(txt3, 2, TriState.False)
Dim txt4 As Decimal
txt4 = (CS_ServiceAdvertising_done.Text / CS_ServiceAdvertising_target.Text) * 100
CS_ServiceAdvertising_Result.Text = "%" + FormatNumber(txt4, 2, TriState.False)
Dim txt5 As Decimal
txt5 = (CS_ServiceCatogray_done.Text / CS_ServiceCatogray_target.Text) * 100
CS_ServiceCatogray_Result.Text = "%" + FormatNumber(txt5, 2, TriState.False)
End Sub
i just show you 5 textbox's of 100 textbox's .... and don't want to complete all the textbox's like this ... i want a simple code to do it..
... as you notice , every three textbox's are look a like on the first two parts of their id's..~
for example -- CS_ServiceCatogray _Result.Text, CS_ServiceCatogray _done.Text and CS_ServiceCatogray _target.Text...
~..and the last part is the same in all textbox's for geving the Result .. _Result.Text , _done.Text and _target.Text
So... i had an idea to take the id and put the Similar two parts in an array... and use For Each something like:
Dim allItems As Array
For Each item As Control In panel4.Controls
Select Case item.[GetType]().Name
Case "TextBox"
'here just be sure that this item is not saved in the allItems array ,if it is not do >>'
allItems[Last_Item_Saved_Index+1] = DirectCast(item, TextBox).ID ', but i want to save just the two Similar parts of the textboxs ids'
'i am not sure if this completely correct, but i wanted to do something like it['
Dim partOFtxt As String = allItems[Last_Item_Saved_Index]
Dim txt As Decimal = (partOFtxt + "_done.Text") / (partOFtxt + "_target.Text")
(partOFtxt + "_Result.Text") = "%" + FormatNumber(txt, 2, TriState.False) ']'
'end condition'
Exit Select
Case Else
Exit Select
End Select
Next
i hope that you get the idea..
if you have a better idea ... it would be nice..
Thanks in advance..