Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: fixed width file


Message #1 by philip.moh@a... on Thu, 31 May 2001 16:20:45 +0800
I once built a DLL to do just this (Parse fixed files) with a complete
Object Oriented design (it was simple).  But the neat part is that it
persisted the Objects (i.e. The Parameter Objects used to parse the file) to
a "Template" file so that the Objects could be retrieved for later use.  It
parsed files really fast too =)!

-----Original Message-----
From: Kim, Cardyin [mailto:CKim@s...]
Sent: Thursday, May 31, 2001 12:22 PM
To: professional vb
Subject: [pro_vb] RE: fixed width file


Philip,

To answer your first question:

You normally woulsn't use the split
function to parse a fixed length file.

Instead you would use a series of
mid$() functions to parse the information
that you need.  For example:

Dim strInput As String
Dim strFirstName As String
Dim strLastName As String

'Here are some examples of lines that may come from a file
strInput = "Cardyin     Kim         "
strInput = "Philip      Moh         "
strInput = "FrankensteinGlockenspiel"

'Here is an example of code to parse the information
strFirstName = Trim$(Mid$(strInput, 1, 12))
strLastName = Trim$(Mid$(strInput, 13, 12))


If you want to expose the properties and
methods in the ide, you must use early
binding instead of late binding:

Private Sub Command1_Click()
  Dim appXcel As Excel.Application
  Set appXcel = New Excel.Application
  
  appXcel.Visible = True
  'your code here...

  appXcel.Quit
  Set appXcel = Nothing
End Sub

Hope this helps.

Cardyin

--------------------------------------
Cardyin Kim
C/S & Web Development Analyst
Information Services
San Antonio Community Hospital
ckim@s...     (xxx)xxx-xxxx     
--------------------------------------


-----Original Message-----
From: philip.moh@a... [mailto:philip.moh@a...]
Sent: Thursday, May 31, 2001 1:21 AM
To: professional vb
Subject: [pro_vb] fixed width file


If it is a comma delimited file, we know that the field is separated by
comma (,) so we can use split(xxx, ",") but if it is a fixed width file, how
can we split it in VB program??? Please help...

BTW, what do I need to set if I want to use the Excel object in my program
so that when I type dot (.) after the Excel object, all it properties or
methods will be listed out eg. Caption, Visible and etc... I have the
following code from someone, it works but I don't get it properties or
method after I type the dot (.) I have set the Microsoft Excel 8.0 Object
Library in the reference but didn't help.

Please advise... this it urgent... many thanks..


Set appXcel = CreateObject("Excel.Application")
appXcel.Workbooks.Open fileName:="c:\Book1.xls"
appXcel.Caption = "This is a test"
appXcel.Visible = True


  Return to Index