Не знаю, почему они так быстро закрыли ваш новый вопрос ... Я строил для него ответ.
- Нажмите на Project -> Add Reference
- Switchк опции COM
- Выберите запись «Microsoft Script Control 1.0» и нажмите «ОК».
Теперь вы можете использовать код, подобный приведенному ниже, создавая код для textCharges1 -> V001 через textCharges25-> V025:
Public Class Form1
Private SC As New MSScriptControl.ScriptControl
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SC.Language = "VBScript"
Dim ctl As Control
Dim ctlName, functionBody As String
functionBody = "Function {0}()" & vbCrLf & vbTab & "{0} = CDbl({1}.Text)" & vbCrLf & "End Function"
For i As Integer = 1 To 25
ctlName = "textCharges" & i
ctl = Me.Controls.Find(ctlName, True).FirstOrDefault
If Not IsNothing(ctl) Then
SC.AddObject(ctlName, ctl, True)
SC.AddCode(String.Format(functionBody, "V" & i.ToString("000"), ctlName))
End If
Next
LABELFIELD2.Text = "V001*V002/100"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim result = SC.Eval(LABELFIELD2.Text)
lblResult.Text = result
Catch ex As Exception
lblResult.Text = "{Error}"
End Try
End Sub
End Class
Рабочий пример:
![enter image description here](https://i.stack.imgur.com/0UuYz.png)