I would like some expert advice. I am writing in VB6. I am opening a tab delimited file, deleting the first 50 lines, and rewriting the file to a temp file. The temp file has about 20 columns with x number of lines. What I am trying to do, is open the tab delimited file, and read each column into a named variable, ex. depth<column1>m pf<column2>tg<c olumn3>,etc. I have written a function to take the variable from column2(mpf) & create another variable(fph) to insert back into the file, at column2. This would move everything from column2(mpf) on, up one column. The columns and variables are as follows:
depth(column1), mpf(column2),tg (column3),c1(co lumn4),etc. with the variables. I need to create the variable fph and insert it into column2, where the new file will read as follows:
depth(column1), fph(column2),mp f(column3),tg(c olumn4),c1(colu mn5),etc to the end of the line. The code I have is as follows: -
Public tFile As String
-
Public mpf As Double
-
Public fSave As String
-
-
Public Function TrimAll(Str)
-
'***remove all non ASCI chrs and reduce internal whitespace to single
-
Dim i, strTemp, strOut, strCh
-
-
strTemp = Str
-
For i = 1 To Len(strTemp)
-
strCh = Mid(strTemp, i, 1) '***look at each character in turn
-
'***if the chr is a space and the previous added chr was a space ignore it
-
'***otherwise add it on
-
If Not (strCh = " " And Right(strOut, 1) = " ") Then
-
strOut = strOut & strCh
-
End If
-
Next
-
TrimAll = strOut
-
End Function
-
-
Private Sub cmdConvert_Click()
-
Dim Script As Object
-
Dim ObjStream As Object
-
Dim strLine As String
-
Dim a As Integer
-
-
'check for .las file
-
Set Script = CreateObject("Scripting.FileSystemObject")
-
If Script.FileExists(tFile) Then
-
a = True
-
Set ObjStream = Script.opentextfile(tFile, 1, False, 0)
-
Else:
-
MsgBox "There is no LAS data in file. Please update with new LAS data.", vbInformation + vbOKOnly
-
a = False
-
Exit Sub
-
End If
-
-
If tFile > "" Then
-
'open file
-
Set Script = CreateObject("Scripting.filesystemobject")
-
Open tFile For Input As #1 'read from this file
-
Open "C:DB_CUETemp.dat" For Output As #2 'write to this file
-
-
'delete header and print rest of data to temp file
-
If a = True Then
-
Dim i As Integer
-
i = 0
-
Do While i < 50 And Not ObjStream.AtEndOfStream
-
strLine = ObjStream.Readline
-
i = i + 1
-
Loop
-
-
Do While Not ObjStream.AtEndOfStream
-
strLine = TrimAll(ObjStream.Readline)
-
YourArray = Split(strLine, " ") '***use the tab key to create space between quotes.***
-
Print #2, strLine
-
Loop
-
End If
-
-
Close #1
-
Close #2
-
-
'save file
-
With CommonDialog1
-
.Filter = "All Files|*.las*|"
-
.InitDir = "C:DB_CUE"
-
.DialogTitle = "Save File As"
-
.ShowSave
-
End With
-
fSave = CommonDialog1.FileName
-
'copy temp file
-
FileCopy "C:DB_CUETemp.dat", fSave '& ".las"
-
'delete temp file once copied
-
Kill "C:DB_CUETemp.dat"
-
-
If MsgBox("File is complete. Would you like to view the file?", vbQuestion + vbYesNo, "LAS iGenerator") = vbYes Then
-
Shell ("Explorer.exe tFile"), vbNormalFocus
-
' Unload Me
-
End If
-
Else:
-
If MsgBox("You must select a file to convert before you can continue.", vbExclamation + vbOKOnly) = vbOK Then
-
Exit Sub
-
End If
-
End If
-
End Sub
Could you help shed some light on this, or refer me to someone who may? Thanks for your time.
Dec 29 '09
11 1911
try... -
Function CalcFPH(ArrayElement As String) as String
-
CalcFPH=60/Int(ArrayElement)
-
End Function
-
and call it thus... -
OutputText = OutputText & ElementArray(0) & vbTab & CalcFPH(ElementArray(1))
-
Good Luck
That works perfectly. Thank you very much for your expertise. Greatly appreciated
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: waters |
last post by:
I seem to have hit a snag.
I am trying to add the list (l_local) as an item in the output list
(l_output). "l_local" is a modified copy of the format-list "l_format",
which will be updated by index position within the function. The problem
occurs in the following statement block:
def create_apid_list(l_format,l_values):
l_output =
for t_curr_line in l_values: # ...for each list in the values list
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: Skc |
last post by:
I am trying to import a file using a custom VB.net procedure, but the problem
is it works on a file with pure comma separation and not inverted commas and
commas, i.e. it works for AAA,BBB,CCC,DDD but not for "AAA","BBB","CCC","DDD".
Here is an extract from the code which needs to be modified for the """:
Sub LoadTextFile(ByVal strFilePath As String)
Dim oDS As New DataSet()
Dim strFields As String
Dim oTable As New DataTable()
|
by: Ben |
last post by:
Hi all -
I am having a bit of trouble and thought maybe someone in this group
could shed some light. Here's the skinny...
I am creating an automated process to import a bunch of text files
into Access. I want to avoid creating a separate "Spec" for each file
(there are over 180 files) and instead want to code my own dynamic
importing rules. So far it's been going fine, except for one item...
|
by: freemann |
last post by:
Can anyone provide example code showing how to send form results to a results
page, email and a comma delimited file? Notice that I need it going to all
three locations.
Details: I have forms created and working. The first form the user fills out
and submits. The form properties are set to Send to other: "Custom ISAPI,
NSAPI, CGI, OR ASP SCRIPTING. The method is "POST" and the action is
"secondpage.asp". I had to go this route because...
| |
by: Masa Ito |
last post by:
I have pipe delimited (and comma/tab) files that I read with JET using a
schema file. Occasionally a field has multiple quotes (") inside a single
field - which chokes the line (the rest of the columns get read as
nulls). An example of an offending line is:
J" Invalid " ....
This is a text field that is between the two 'pipes' so I need it read
exactly as is.
I have reverted to schema files, trying everything I can to overcome this...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
'--this code works but only reads text into one column when contains multiple
cols
Dim ds1x As New DataSet
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dir1A\;Extended
Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn1x As New OleDb.OleDbConnection(ConStr)
Dim dax1 As New OleDbDataAdapter("Select * from testabc1x.txt", conn1x)
|
by: RyanL |
last post by:
I'm a newbie! I have a non-delimited data file that I'd like to
convert to delimited.
Example...
Line in non-delimited file:
0139725635999992000010100534+42050-102800FM-15+1198KAIA
Should be:
0139,725635,99999,2000,01,01,00,53,4,+42050,-102800,FM-15,+1198,KAIA
|
by: kimmelsd33 |
last post by:
I am using VB6. I want to read a tab delimited file, and assign each column value into a variable. If the variable is "-999.25", I want to make it a "0". I then want to reassemble the values, and write them to a temp text file. Starting with line 64, I have about 28 columns and x number of rows. Ex: 1000<tab>23.3<tab>-999.25<tab> etc. The value of -999.25 can be in any column. I need to replace it before it is stored in the variable. I need to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |