Option Explicit
Private Declare PtrSafe Sub callTModel Lib "D:\FS\LTMProjekt\TestWB\CLM_WEAdynModell.dll" (ByRef IOArray() As Single)
Private Sub CB_RUN_Click()
Dim ValID, TStep, INLimit, aIndex, bIndex, ActSensor, VisNmax, OUTLimit, i As Integer
Dim TSim, TMax As Single
Dim IOArray(149) As Single
With ActiveSheet
TStep = 0
ValID = 0
INLimit = 9
VisNmax = 20
ActSensor = .Range("NoSensor").Value + 1
OUTLimit = .Range("OUTLimit")
TSim = 0
TMax = .Range("TMax")
ThisWorkbook.Worksheets("IstRes").Range("A4:IV8000").ClearContents
Application.ScreenUpdating = False
Do While TSim < TMax
TSim = .Range("TSim")
aIndex = (4 + TStep) 'Zeilenindex für Source Array
For i = 1 To INLimit
bIndex = (1 + i) ' Spaltenindex für Source Array
If (i < 10) Then IOArray(24 + i) = ThisWorkbook.Worksheets("SourceData").Cells(aIndex, bIndex).Value
bIndex = bIndex + INLimit
If (i < 10) Then IOArray(39 + i) = ThisWorkbook.Worksheets("SourceData").Cells(aIndex, bIndex).Value
bIndex = bIndex + INLimit
If (i < 4) Then IOArray(7 + i) = ThisWorkbook.Worksheets("SourceData").Cells(aIndex, bIndex).Value
bIndex = bIndex + 3
If (i < 4) Then IOArray(19 + i) = ThisWorkbook.Worksheets("SourceData").Cells(aIndex, bIndex).Value
Next i
IOArray(101) = OUTLimit
Call callTModel(IOArray)
aIndex = (4 + TStep) 'Zeilenindex für Target Array
ThisWorkbook.Worksheets("IstRes").Cells(aIndex, 1).Value = ThisWorkbook.Worksheets("SourceData").Cells(aIndex, 1).Value
For i = 1 To OUTLimit
bIndex = (1 + i) ' Spaltenindex für Source Array
ThisWorkbook.Worksheets("IstRes").Cells(aIndex, bIndex).Value = IOArray(101 + i)
Next i
Application.ScreenUpdating = True
If TStep < VisNmax Then
.Cells(9 + TStep, 3).Value = ThisWorkbook.Worksheets("SollRes").Cells(aIndex, ActSensor).Value
.Cells(9 + TStep, 4).Value = ThisWorkbook.Worksheets("IstRes").Cells(aIndex, ActSensor).Value
Else
For i = 1 To (VisNmax - 1)
.Cells(8 + i, 3).Value = .Cells(9 + i, 3).Value
.Cells(8 + i, 4).Value = .Cells(9 + i, 4).Value
Next i
.Cells(8 + VisNmax, 3).Value = ThisWorkbook.Worksheets("SollRes").Cells(aIndex, ActSensor).Value
.Cells(8 + VisNmax, 4).Value = ThisWorkbook.Worksheets("IstRes").Cells(aIndex, ActSensor).Value
End If
TStep = TStep + 1
.Range("TStep") = TStep
Call ScrUpdateEnableNoFlicker
Application.ScreenUpdating = False
Loop ' Ende DoWhile TSim <= TMax
End With ' ActiveSheet
'Application.ScreenUpdating = True
End Sub