473,836 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read and display specific data from text file into listbox using VB 6

Mas Juliza Alias
67 New Member
Hi,

I am building a program on Information System for Reservoir Operation for my Masters research. Now I have a text file which is an output file from a processing software (Terramodel) that lists out Elevation Range and Volume in columns and rows. The text file looks like this;

-------------------------------------------------
-software's distributor address-
-project description-

Depth range Volume
(m) (m3)
0.000 > 0.001 10.0
0.001 > 0.002 12.0
. .
. .
. .

cummulative volume
(m3)
500
-------------------------------------------------

now i've written the code to display the data in listbox using AddItem, but the whole lines are displayed in one single line in the listbox. I want to display only the Depth Range and Volume data, starting from '0.000 > 0.001'. So, how to skip reading the file header (software's distributor address & project description) and the data column's header (Depth range (m) & Volume (m3))?

Thank You for your time.
Sep 24 '10
21 10155
Mas Juliza Alias
67 New Member
THANKS for the explanation. it REALLY helps my understanding on your code :)

but there's one line i can't understand.
Expand|Select|Wrap|Line Numbers
  1. FrameCol(Index).Left = TextEdit.Left + 45 + (Val(TextCol(Index)) * 120)
why + 45? and why * 120? sorry for my limited knowledge on this.

the values in the grid should be in Double, because they will be used in later calculations. i've tried to change String to Double but they turns out values without the decimal points. how can we fix this?

yes, i agree with the CommonDialog idea. i already have it in previous dialog of downloading the data in this program. i'll edit your code in reading the file from App.Path to the datafile selected by user.

tq, hope to hear from u soon.
Nov 3 '10 #11
Guido Geurs
767 Recognized Expert Contributor
Framecol(index) are the red and blue lines over the textbox.
To place them on the right place on the textbox: the .Left dimension =
- TextEdit.Left = left side of the textbox
- + 45 [twips] = 3 pixels for the frame of the textbox
- + (Val(TextCol(In dex)) * 120) = the value of spaces we have set * 120 [twips] (= 8 pixels)
Remark: You have to use a font in the textbox with for each char the same width = Fixedsys, ... NOT Arial, ...!
You can experiment with these values and see what happens.
Also use the same font for the ruler !

Ok I will place the values in Double and find a way to make them visible with dot-zeros.
I wll also implement the commondialog and the settings of the default values.
Nov 3 '10 #12
Guido Geurs
767 Recognized Expert Contributor
I don't think it's possible to place the values in the grid in a Double format.
The grid has only String formats in the cells.
If You want the values later for calculation, You have to read them in the grid as string and transform them with CDbl(...) in the calculation code.

Attached are the latest modifications
Nov 3 '10 #13
Mas Juliza Alias
67 New Member
this code is perfect! now i want to read the data in the grid, do some calculation to the data, and display them in another table- in another form, perhaps. are the data of Depth1, Depth2, CutVol, and FillVol in array? let say in the new table there are 2 columns: 1)Depth 2)Volume
here's the whole picture:-

MSFlexGrid1____ _______________ ______
Depth1 | Depth2 | CutVol | FillVol |
------------------------------------
-5.00 | -4.00 | 41.0 | |
-4.00 | -3.00 | 51.9 | |
-3.00 | -2.00 | 64.1 | |
-2.00 | -1.00 | 77.5 | |
-1.00 | 0.00 | 92.2 | |
------------------------------------

and the new table should be like this:-

MSFlexGrid2____ _______________ ______
Depth | Volume |
-----------------
-5.00 | 0.00 | 'Volume(1) always being 0.00
-4.00 | 41.0 | '=CutVol(1) + Volume(1)
-3.00 | 92.9 | '=CutVol(2) + Volume(2)
-2.00 | 157.0 | '=CutVol(3) + Volume(3)
-1.00 | 234.5 | '=CutVol(4) + Volume(4)
0.00 | 326.7 | '=CutVol(5) + Volume(5)
-----------------

how to read the data from MSFlexGrid1, do some calculation on them, and display the result in MSFlexGrid2?

thanks a lot for your continuous help. i REALLY appreciate that.
Nov 10 '10 #14
Guido Geurs
767 Recognized Expert Contributor
I hope this will help ( see attachment)
Attached Files
File Type: zip Read and display specific data_v5.1.zip (40.2 KB, 256 views)
Nov 11 '10 #15
Mas Juliza Alias
67 New Member
i have tried running the program but the result (Volume) is not accurate. i have attached the data i used and the result should be the same as in my previous post. for this text data (DATUM_0.txt), there should be 6 lines of Depth and Volume filled in the grid (Depth= -5.000, -4.000, -3.000, -2.000, -1.000, 0.000). i tried to edit your code but i fail to get the result as i described above.

thank you for your time...
Attached Files
File Type: txt DATUM_0.txt (1.6 KB, 453 views)
Nov 12 '10 #16
Guido Geurs
767 Recognized Expert Contributor
In Your datafile there is no line with 0.000 so it is not taken in consideration by setting up the ARRAYDATA.
Must there always be a last line , not present in the data file?
I suppose it will not always be 0.000 ?
If so You will have to add it in the TextEdit window like in the next example You will have to add O.OO2 with no values?:
...
...
0.000 > 0.001 10.0
0.001 > 0.002 12.0
O.OO2

If so i must change the code because the splitting of the last line will give an error because there are no spaces in the line !!!
Nov 12 '10 #17
Guido Geurs
767 Recognized Expert Contributor
Is it in the data input file always a constant value between the depth1's ?
If so, I can integrate it in the code.
Nov 13 '10 #18
Mas Juliza Alias
67 New Member
the last line of Depth column (in the new form) should be the last value of Depth2. can that be coded?

yes, the values between the Depth1 are always constant within a single file. other files may use other constant values.
Nov 15 '10 #19
Guido Geurs
767 Recognized Expert Contributor
I hope this will help: see attachment
Attached Files
File Type: zip Read and display specific data_v5.3.zip (20.3 KB, 288 views)
Nov 15 '10 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3165
by: sachin10 | last post by:
hi i m sachin, i m new to VB programming.i face some problem regarding the sorting of text file contents using arrays.text file have data in the format as below seq |consumerid|status1|status2|meter no1|meter no2|nameof consumer|routeno 234133210003040002222222222000003333333123098sasdcscasdsadsd9041 231433104000267232222278222000003333333123098shskdfkscasdsade9012 this is the format of text file.there are thosands of records in this...
1
2205
by: christine0207 | last post by:
Hi, how to generate a fixed length data text file using Scripting.TextStream / filesystemobject.
2
1355
by: JMG | last post by:
Hi All, I have no idea if this is the correct place to post this question, but I'm hoping so :). My problem is that I have a text file containing 5 sets of passwords on a single line space delimited line, which is used to change passwords on a daily basis via DOS batch files (don't get me started on why we have to do it this way, we just do...>:) ) ie Monpassword Tuepassword Wedpassword Thurpassword Fripassword in passwords.txt
2
5521
by: RyanS09 | last post by:
Hi- I have read many posts with specific applications of reading in text files into arrays, however I have not been able to successfully modify any for my application. I want to take a text file filled with a tab delimited list of 10 columns (floats) and read it into a 2D array. The length of the columns are all the same, however this will be variable from text file to text file. Any help (starter code or where to read) would be much...
2
3387
by: JB | last post by:
I'm trying to read a text file, and store the position of a specified line, and then later seek back to that line and start reading again. I'm using simple code like the following: StreaReader sr = new StreamReader("test.txt"); String s = ""; while (S != null) { S = sr.ReadLine()
1
1732
by: Paul Lemelle | last post by:
I am trying to read in a text file then use the data in the file. I know how to read a file wiht the System.IO namespace: FileRead fr = new StreamReader("data.txt"); Console.Writeline(fr.Readline()); or StreamReader fr = File.OpenText("Data.txt");
3
7412
by: printline | last post by:
Hello All I need a little help with a phph script to display some specific data from a mysql table. I have a mysql table with 4 columns and 10 rows. I want to display fx. data from row 4, 6, 8 and 10. I can display either the first row or all the rows using the below code: $row = mysql_fetch_array($result) or die(mysql_error()); echo $row. " - ". $row. " <img src=images/arlon.jpg /> ". $row. " - ". $row;
1
1682
by: MiziaQ | last post by:
How can I delete a row of data from a data/text file in vb6 ? I am using an MSFlexGrid, so the user can select which row is to be deleted. Thanks in advance, MiziaQ
13
10466
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another set of integers stored in an array.It would be a great help if you could provide some code for it.I tried the function fscanf but by that I am able to read only the first integer of the text file.Please help me.
0
2000
by: rahulsapra | last post by:
hello everyone m new to j2me plzz help I have a text file that contains data line by line.. format is : response:<some text><space>Pin:<some text><space>time:<hh:mm:ss> eg response:invalid pin Pin:1111 time:04:04:16
0
9664
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10832
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10584
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,...
0
10248
tracyyun
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...
0
9367
agi2029
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...
1
7782
isladogs
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...
0
6976
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();...
0
5815
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.