Re: Excel in VB 6.0
- From: "Rick Rothstein" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Jun 2005 09:42:43 -0400
I don't think so. I think the Microsoft Excel Work*** **is** Excel,
isn't it? (I don't know for sure since I have never had the need to use
it.) You could use a grid control to display the information parsed out
from the arrays my code formed and let the user edit that. Then, when
the that portion of the program concludes, read the data directly from
the grid back into an comma or pipe delimited String for saving out to
the hard disk.
Rick - MVP
"Rachel" <Rachel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E225BFC4-D7F4-48F6-BB7F-6A3D666B06E5@xxxxxxxxxxxxxxxx
> Rick you are great thanks for the answer, is there a way to use the
component
> called Microsoft Excel Work*** control for easy display of this data
in my
> application? I want the user to have the ability of modifying data
within
> the application in a spread*** that is similar to Excel without
actually
> opening Excel. I am willing to use a grid control too. Any ideas?
>
> "Rick Rothstein" wrote:
>
> > > I need the ability of opening a pipe or comma delimited file in VB
6.0
> > and
> > > be able to modify the file and save it back as pipe or comma
> > delimited, but I
> > > do not want to open an Excel application to do this.
> >
> > See if this helps you out any...
> >
> > You can load the entire file into a String variable like this...
> >
> > Dim X As Long
> > Dim FileNum As Long
> > Dim Delimiter As String
> > Dim TotalFile As String
> > Dim Fields() As String
> > Dim Records() As String
> > FileNum = FreeFile
> > ' Reads the second file into memory all at once
> > Open "c:\SomeDircectory\YourFile.txt" For Binary As #FileNum
> > TotalFile = Space(LOF(FileNum))
> > Get #FileNum, , TotalFile
> > Close #FileNum
> >
> > where TotalFile is the String variable that contains the entire
file.
> > You can now use the Split function to separate each record (Row)
into
> > individual array elements like so...
> >
> > Records = Split(TotalFile, vbNewLine)
> >
> > and then further split it out into individual fields per record...
> >
> > If InStr(TotalFile, "|") > 0 Then
> > ' Assume the file is pipe delimited
> > Delimiter = "|"
> > Else
> > ' Otherwise, assume comma delimited
> > Delimiter = ","
> > End If
> > For X = 0 To UBound(Records)
> > Fields = Split(Records(X), Delimiter)
> > ' You now have access to the individual fields
> > ' within the Record #X, via the array elements
> > ' of the Fields array, so edit them in anyway
> > ' that you want or need to here.
> > '
> > ' <<your editing code goes here>>
> > '
> > ' When finished, put he record back together again
> > Records(X) = Join(Fields, Delimiter)
> > Next
> >
> > And now that you have processed the entire, file, put the TotalFile
back
> > together again...
> >
> > TotalFile = Join(Records, vbNewLine)
> > ' Then save it back out to the hard drive
> > FileNum = FreeFile
> > Open "c:\SomeDircectory\YourFile.txt" For Output As #FileNum
> > Print #FileNum, TotalFile
> > Close #FileNum
> >
> > and you should be done. Note, this is top of the head code, so try
it
> > out on a copy of your file to make sure it works correctly BEFORE
> > implementing it for actual use in your project.
> >
> > Rick - MVP
> >
> >
.
- References:
- Excel in VB 6.0
- From: Rachel
- Re: Excel in VB 6.0
- From: Rick Rothstein
- Re: Excel in VB 6.0
- From: Rachel
- Excel in VB 6.0
- Prev by Date: Re: Help me understand
- Next by Date: Re: What are these ASCII values?
- Previous by thread: Re: Excel in VB 6.0
- Next by thread: Using VB.NET in the Real World
- Index(es):