Hallo.
Ich habe 2 Subs bzw eine Sub und eine Funktion, die als Boolean funzt. Wie kann man solche Subs zusammenlegen / umschreiben zu einer einzigen Sub, die trotzdem die Funktionalität hat, wie beide zusammen?
Starten möchte ich die Sub dann mit der "Handles MyBase.Load"-Sub.
Ich habe 2 Subs bzw eine Sub und eine Funktion, die als Boolean funzt. Wie kann man solche Subs zusammenlegen / umschreiben zu einer einzigen Sub, die trotzdem die Funktionalität hat, wie beide zusammen?
Starten möchte ich die Sub dann mit der "Handles MyBase.Load"-Sub.
Quellcode
- Private Function Initialize() As Boolean
- Try
- Dim Kopfzeile As String
- Dim i, j As Integer
- Dim FileColumnNames() As String
- Dim InputName As String
- Dim NameCounter As Integer
- Call DR1.LoadDataRecApp(TextBox5.Text)
- ReDim InputParameter(DR1.ParameterCount)
- For i = 1 To DR1.ParameterCount
- With InputParameter(i)
- .Min = DR1.Parameters(i).Min
- .Max = DR1.Parameters(i).Max
- .RelError = DR1.RelativeModelAccuracy(i)
- .AbsError = DR1.AbsoluteModelAccuracy(i)
- End With
- Next
- If RecordNumber > 0 Then
- sr.Close()
- sw.Close()
- End If
- InputFileName = TextBox6.Text
- If InputFileName = "" Then InputFileName = DR1.Path & "\" & DR1.Application & ".pat"
- sr = New IO.StreamReader(InputFileName)
- LineString = sr.ReadLine
- FileColumnNames = LineString.Split(CChar(";"))
- ReDim ColumnPointer(DR1.ParameterCount)
- For i = 1 To DR1.ParameterCount
- InputName = DR1.Parameters(i).Name
- ColumnPointer(i) = -1
- NameCounter = 0
- For j = 0 To FileColumnNames.GetUpperBound(0)
- If FileColumnNames(j) = InputName Then
- ColumnPointer(i) = j
- NameCounter += 1
- End If
- Next
- If NameCounter > 1 Then
- MsgBox("Multiple occcurence of column name: " & InputName)
- Exit Function
- End If
- If ColumnPointer(i) < 0 Then
- MsgBox("Input not found in file: " & InputName)
- Exit Function
- End If
- Next
- For i = 1 To DR1.ParameterCount
- Debug.Print(CStr(i) & " " & ColumnPointer(i) & " " & DR1.Parameters(i).Name & " " & FileColumnNames(ColumnPointer(i)))
- Next
- OutputFilename = TextBox7.Text
- sw = New IO.StreamWriter(OutputFilename)
- Kopfzeile = "No.;"
- For i = 1 To DR1.ParameterCount
- Kopfzeile += DR1.Parameters(i).Name & "_meas;"
- Next
- sw.WriteLine(Kopfzeile)
- RecordNumber = 0
- Initialize = True
- Catch ex As Exception
- MsgBox(ex.Message)
- Initialize = False
- Exit Function
- End Try
- End Function
- Private Sub EvaluateRecord()
- Try
- Dim i As Integer
- Dim Zeile, hString As String
- Dim ActiveRecord, ARSplit() As String
- If Not sr.EndOfStream Then
- ActiveRecord = sr.ReadLine
- RecordNumber += 1
- ARSplit = ActiveRecord.Split(CChar(";"))
- For i = 1 To DR1.ParameterCount
- DR1.InPut(i) = ARSplit(ColumnPointer(i))
- Next
- DR1.EvalF()
- Zeile = CStr(RecordNumber) & ";"
- For i = 1 To DR1.ParameterCount
- hString = ""
- If IsNumeric(ARSplit(ColumnPointer(i))) Then hString = ARSplit(ColumnPointer(i))
- Zeile += hString & ";" & DR1.OutPut(i) & ";"
- Next
- Zeile += DR1.ValueIncompleteCount & ";" & DR1.Iterations & ";" & DR1.deltarel & ";" & DR1.PCA_MaximumNumberIterations & ";" & DR1.PCA_ReconstructionAccuracy
- sw.WriteLine(Zeile)
- TextBox1.Text = CStr(RecordNumber)
- Me.Refresh()
- Else
- sr.Close()
- sw.Close()
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- sr.Close()
- sw.Close()
- Exit Sub
- End Try
- End Sub