reading vb file into delphi 
Author Message
 reading vb file into delphi

Could any one please help me i have a Visual Basic file that I want to
read in delphi.

The Type of the vb file is defined as follows:

Type Spg
  M22FB As Integer
  M2310 As Single
  M2325 As Integer
  M233A As Long
  M2351 As String * 60
  M2360 As Integer
  M2373 As Integer
  M2386 As Integer
  M2398 As Integer
  M23AA As Integer
  M23BB As Integer
  M23CB As Integer
  M23DC As Integer
  M23ED As Integer
  M2403 As Integer
  M241D As Integer
  M2435 As Integer
  M2449 As Integer
  M245C As String * 10
  M2470 As String * 40
  M247F As String * 40
  M248E As String * 40
  M249D As String * 40
  M24AC As String * 1780
End Type

I have tryed the following in delphi but it dosnt seem to work proberly

unit UFilindlaes;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
  StdCtrls;

type

  TSpg = record
          M22FB : word;
          M2310 : Smallint;
          M2325 : word;
          M233A : word;
          M2351 : String[60];
          M2360 : word;
          M2373 : word;
          M2386 : word;
          M2398 : word;
          M23AA : word;
          M23BB : word;
          M23CB : word;
          M23DC : word;
          M23ED : word;
          M2403 : word;
          M241D : word;
          M2435 : word;
          M2449 : word;
          M245C : String[10];
          M2470 : String[40];
          M247F : String[40];
          M248E : String[40];
          M249D : String[40];
          M24AC : String[255]; //1780
        end;

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
   gv0168 : T000A;
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Sti: string;
SdbFil:file of TSpg;
gv0168:TSpg;
svar : Integer;
begin
Sti:='c:\surveysd\airline.sdb';
  //if OpenDialog1.execute=true then
   AssignFile(SdbFil,sti);//Opendialog1.FileName);
  try
    reset(SdbFil);
    try
         Read(SdbFil,gv0168);
    finally
      CloseFile(SdbFil);
    end;
  except
    on EInOutError do
     svar:= application.MessageBox('Kan ikke finde filen',
                                   'Programmet kr?ver x-file'
                                   ,mb_iconStop or mb_ok);
  end;

end;

end.

Airline.sdb is the file to read.

Thanks in advance

 Allan

[ Airline.sdb 81K ]

AIRPORT SERVICES


AIRPORT SERVICES


AIRPORT SERVICES


AIRPORT SERVICES

Baggage check-in??0  Excellent?0  Good?0  Fair?0  Poor?0  No Opinion?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
...

read more »



Wed, 18 Jun 1902 08:00:00 GMT  
 reading vb file into delphi

Quote:

> Could any one please help me i have a visual basic file that I want to
> read in delphi.

Try a Delphi group?


Tue, 29 Apr 2003 07:35:06 GMT  
 reading vb file into delphi

Quote:

> The Type of the vb file is defined as follows:

> Type Spg
>   M22FB As Integer
>   M2310 As Single
>   M2325 As Integer
>   M233A As Long
>   M2351 As String * 60

[...]

Quote:
> I have tryed the following in delphi but it dosnt seem to work proberly

>   TSpg = record
>           M22FB : word;
>           M2310 : Smallint;
>           M2325 : word;
>           M233A : word;
>           M2351 : String[60];

I'm not sure how VB and Delphi types correlate, but I see some serious
problems here.

A VB integer may well be the same length as a Delphi word (check this; is it
true?) - this will be okay *only* if you know that the integers you read in
will *never* be negative. If they are not the same length, try to find a
type that is the same length.

If VB integer and Delphi word are the same size, it is unlikely that a VB
Long and a Delphi word will also be the same size! Try a double-word or
longint kind of type (I don't know what it's called in Delphi). Again, make
sure you get something the same size (i.e. number of bytes). Also, make sure
the Delphi type supports negative numbers unless you can guarantee that
negative numbers will never be stored in that field.

Finally, a VB Single and a Delphi Smallint are definitely *not* going to be
equivalent. Delphi will almost certainly have a Single type, which *should*
be compatible with VB's (assuming they both implement the IEEE standard).
Use that instead. But "smallint" is an integer type, and "single" is a
floating-point type. Even if they are the same length -- and I doubt a
"smallint" would be four bytes long -- they would be interpreted very
differently.

Check the length in bytes of each of your types. Until you get them matching
you definitely won't be able to read the file properly.

Once you've fixed all this, if you're still having problems post in a Delphi
group, where they can comment on your actual code.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Tue, 29 Apr 2003 09:14:18 GMT  
 reading vb file into delphi


:> The Type of the vb file is defined as follows:

:I'm not sure how VB and Delphi types correlate, but I see some serious
:problems here.

Please always redirect the Delphi-only related answers away from









   All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa

Timo's  FAQ  materials  at   http://www.uwasa.fi/~ts/http/tsfaq.html



Tue, 29 Apr 2003 13:02:29 GMT  
 reading vb file into delphi

Quote:



> :> The Type of the vb file is defined as follows:

> :I'm not sure how VB and Delphi types correlate, but I see some serious
> :problems here.

> Please always redirect the Delphi-only related answers away from


Apologies, Timo, but what I wrote in my reply was not IMHO a Delphi-only
answer; the points I made apply equally well to someone trying to read a
data file generated in VB into a TP program. One must still ensure that
the sizes of corresponding types are equal, and that they will be
interpreted in the same manner.

Indeed, if the answer had required any knowledge of Delphi, I wouldn't
have been able to write it.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 reading vb file into delphi

Manuka) schreibt:

Sorry, I missed the begin of this thread. The following remarks are intended
for the original poster.

Thanks for using my VB decompiler. Did you already register?
Therefore I assume it's a 16 bit VB program.

Quote:
>> Type Spg
>>   M22FB As Integer <- is SmallInt
>>   M2310 As Single <- is Single
>>   M2325 As Integer
>>   M233A As Long <- is LongInt
>>   M2351 As String * 60 <- is array[1..60] of char (or [0..59])

VB strings of a fixed size have no character count stored.

And don't forget $A- ($Align Off), the records (in files) are not aligned.

DoDi



Wed, 30 Apr 2003 11:21:12 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Intermediate (object) file generation in VB and Delphi

2. CloseFile in Delphi DLL not Closing File till Dll Unloads when called from VB

3. Using Crystal Reports (VB Edition) to read Paradox 5.0 db

4. NEW! VB-Delphi, C++Delphi References

5. Can Delphi read Lotus Notes data files?

6. Reading COBOL files in TP (Delphi)

7. read foxpro files in delphi

8. How can I read LOTUS APPROACH files with Delphi

9. Text File Read / Dbase file Write

10. Identifying files / reading files

11. Reading a file with ctrl Z before end of file

12. Interbase: I/O error for file KATALOG.GDB - Error while trying to read from file

 

 
Powered by phpBB® Forum Software