Hi Guys,
Thanks for reading the post.
I have a peice of code which is written in Visual Basic, and in short, it makes a connection to a server and populates a VB 'Grid' with the data i've requested.
What I would like to do is to adjust the code so it populates an array of double with the data (in leiu of the Grid) and returns it as a result to my delphi application by means of a .dll.
I however, cannot do any of that. So before I learn how, can anyone see any major problems with where i'm headed?
And if the above is possible, does anyone have any top tips or hints on how best to tackle this one?
Many thanks,
Kay
Here is the code I'll be using;
Private Sub DDEBars_Change()
'
' The data returned is a text string with commas
' delimiting fields and semicolons delimiting records
'
' The first record is a series of text labels matching the
' data that you requested
'
' Then there is 1 record of values for each bar requested
Dim StrPos, StrLen, NextDelimiter, NumRows, NumColumns
TextBackFromSVR = DDEBars.Caption
If TextBackFromSVR <> "" Then
RecordStrLen = InStr(1, TextBackFromSVR, ";")
RecordStr = Mid(TextBackFromSVR, 1, RecordStrLen - 1)
StrPos = 1
NumRecords = 1
StrLen = InStr(StrPos, RecordStr, ",") ' Find delimiter.
While StrLen > 0
NumRecords = NumRecords + 1
StrPos = StrPos + StrLen
NextDelimiter = InStr(StrPos, RecordStr, ",")
StrLen = NextDelimiter - StrPos + 1 ' Find next delimiter.
Wend
NumRows = CInt(CBBars.Text) - 1
Grid1.Rows = NumRows + 2
NumColumns = NumRecords
Grid1.Cols = NumColumns
' show the labels
Grid1.Row = 0
StrPos = 1
StrLen = InStr(StrPos, RecordStr, ",") ' Find delimiter.
For c = 0 To NumRecords - 1
Grid1.Col = c
Grid1.Text = Mid(RecordStr, StrPos, StrLen - 1)
StrPos = StrPos + StrLen
NextDelimiter = InStr(StrPos, RecordStr, ",")
If NextDelimiter <> 0 Then
StrLen = NextDelimiter - StrPos + 1 ' Find next delimiter.
Else
StrLen = Len(RecordStr) - StrPos + 2
End If
Next c
' show the values
For r = 1 To NumRows + 1
NextRecordDelimiter = InStr(RecordStrLen + 1, TextBackFromSVR, ";")
RecordStr = Mid(TextBackFromSVR, RecordStrLen + 1, NextRecordDelimiter - RecordStrLen - 1)
RecordStrLen = NextRecordDelimiter
Grid1.Row = r
Grid1.Col = 0
StrPos = 1
StrLen = InStr(StrPos, RecordStr, ",") ' Find next delimiter.
For c = 0 To NumColumns - 1
Grid1.Col = c
Grid1.Text = Mid(RecordStr, StrPos, StrLen - 1)
If c <> 0 Then
If Grid1.Text <> "Invalid" Then
Grid1.Text = CLng(Mid(RecordStr, StrPos, StrLen - 1))
End If
End If
StrPos = StrPos + StrLen
NextDelimiter = InStr(StrPos, RecordStr, ",")
If NextDelimiter <> 0 Then
StrLen = NextDelimiter - StrPos + 1 ' Find next delimiter.
Else
StrLen = Len(RecordStr) - StrPos + 2
End If
Next c
Next r
End If
Thanks for reading the post.
I have a peice of code which is written in Visual Basic, and in short, it makes a connection to a server and populates a VB 'Grid' with the data i've requested.
What I would like to do is to adjust the code so it populates an array of double with the data (in leiu of the Grid) and returns it as a result to my delphi application by means of a .dll.
I however, cannot do any of that. So before I learn how, can anyone see any major problems with where i'm headed?
And if the above is possible, does anyone have any top tips or hints on how best to tackle this one?
Many thanks,
Kay
Here is the code I'll be using;
Private Sub DDEBars_Change()
'
' The data returned is a text string with commas
' delimiting fields and semicolons delimiting records
'
' The first record is a series of text labels matching the
' data that you requested
'
' Then there is 1 record of values for each bar requested
Dim StrPos, StrLen, NextDelimiter, NumRows, NumColumns
TextBackFromSVR = DDEBars.Caption
If TextBackFromSVR <> "" Then
RecordStrLen = InStr(1, TextBackFromSVR, ";")
RecordStr = Mid(TextBackFromSVR, 1, RecordStrLen - 1)
StrPos = 1
NumRecords = 1
StrLen = InStr(StrPos, RecordStr, ",") ' Find delimiter.
While StrLen > 0
NumRecords = NumRecords + 1
StrPos = StrPos + StrLen
NextDelimiter = InStr(StrPos, RecordStr, ",")
StrLen = NextDelimiter - StrPos + 1 ' Find next delimiter.
Wend
NumRows = CInt(CBBars.Text) - 1
Grid1.Rows = NumRows + 2
NumColumns = NumRecords
Grid1.Cols = NumColumns
' show the labels
Grid1.Row = 0
StrPos = 1
StrLen = InStr(StrPos, RecordStr, ",") ' Find delimiter.
For c = 0 To NumRecords - 1
Grid1.Col = c
Grid1.Text = Mid(RecordStr, StrPos, StrLen - 1)
StrPos = StrPos + StrLen
NextDelimiter = InStr(StrPos, RecordStr, ",")
If NextDelimiter <> 0 Then
StrLen = NextDelimiter - StrPos + 1 ' Find next delimiter.
Else
StrLen = Len(RecordStr) - StrPos + 2
End If
Next c
' show the values
For r = 1 To NumRows + 1
NextRecordDelimiter = InStr(RecordStrLen + 1, TextBackFromSVR, ";")
RecordStr = Mid(TextBackFromSVR, RecordStrLen + 1, NextRecordDelimiter - RecordStrLen - 1)
RecordStrLen = NextRecordDelimiter
Grid1.Row = r
Grid1.Col = 0
StrPos = 1
StrLen = InStr(StrPos, RecordStr, ",") ' Find next delimiter.
For c = 0 To NumColumns - 1
Grid1.Col = c
Grid1.Text = Mid(RecordStr, StrPos, StrLen - 1)
If c <> 0 Then
If Grid1.Text <> "Invalid" Then
Grid1.Text = CLng(Mid(RecordStr, StrPos, StrLen - 1))
End If
End If
StrPos = StrPos + StrLen
NextDelimiter = InStr(StrPos, RecordStr, ",")
If NextDelimiter <> 0 Then
StrLen = NextDelimiter - StrPos + 1 ' Find next delimiter.
Else
StrLen = Len(RecordStr) - StrPos + 2
End If
Next c
Next r
End If