Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Utilising a VB 'Grid' in My Delphi Application. 1

Status
Not open for further replies.

kaywarner

Technical User
Jan 8, 2010
24
GB
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
 
Do you need to go through the DLL? You could have your application connect to the server and gather the data yourself.
 
Thanks for your post DJangman,

If i'm honest, I don't know what i need!!

But that sound great to access it myself.

the company who supply the information i'm trying to access say that their API's are accessable by 'any language that supports COM automation'.

I was looking for a work around so as I didn't have to get involved with COM automation.

So would you suggest that I just man-up and learn this COM business?

 
COM isn't that bad. There are lots of links on how to get started with Delphi and COM. Personally I find it easier to work with COM through VB because Delphi makes you enter in all of the parameters. But Delphi will run the COM interface much faster than VB. If you can get documentation on the interface you shouldn't have too much difficulty.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top