473,383 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

losing data when writing into a txt file

3
hi all,

I have posted this problems already, i am posting it again as i have not asked the question. My problem is I have a data around 24320 lines in a txt file. when i am transforming each value and writing it into another text file i am able to write only around 22000, the other values are not writen into the file I am not able to find the solution as I do not know the reason why it is happening so. Please suggest a solution for this problem my code is

//code starts:
Dim abArray()
Dim t As Long
Dim x
count = 0



fName = "data\" & "TT1" & ".TXT"

Open fileN For Input As #3

On Error GoTo ErrorHandler

Do While Not EOF(3)

Line Input #3, x

Counter = 0

Open fName For Input As #14

Do While Not EOF(14) ' Outer loop.
'If t = 1790 Then
' MsgBox ("ok")
'End If
Counter = Counter + 1

Line Input #14, y

If x = y Then

ReDim Preserve abArray(t)

abArray(t) = Hex(Counter)

t = t + 1
count = count + 1

Exit Do ' Exit inner loop.

End If


Loop
Close #14

'If count > 30160 Then
' MsgBox ("ok")
'End If


Loop

Close #3

fileNK = file & "1" & ".txt"
Open fileNK For Append As #13

p = 0
For t = LBound(abArray) To UBound(abArray)
p = abArray(t)
g = Len(p)
If g = 1 Then
Print #13, "0" & p

Else
' If t = 22312 Then
'MsgBox ("ok")
'End If

Print #13, abArray(t)

End If
Next t

Close #13

Set pnlX = Form1.StatusBar1.Panels(3)
pnlX = "Generation of Family Keys Complete"

ErrorHandler:
On Error Resume Next

Code Ends//

thankyou
Jul 30 '08 #1
1 729
janders468
112 Expert 100+
I wasn't able to quite follow all of your code but it sounds like you are wanting to open one file and copy that to another. My feeling is that you may be experiencing troubles with hardcoding the file numbers, but I could be off. The below subroutine will do what you want. Typically if your going to use this method of opening files you want to use the freefile function to determine a free file number and ensure that you properly close all of those file handles. If you don't then it won't write the buffered characters to the underlying file. There are many methods you could go about doing this, but I tried to keep this close to the IO methods you were using. Let me know if this is what you are looking for.
Expand|Select|Wrap|Line Numbers
  1. Sub CopyFile(FileFrom As String, FileTo As String)
  2.     Dim intFile As Integer
  3.     Dim strBuffer As String
  4.     intFile = FreeFile
  5.     Open FileFrom For Input As #intFile
  6.     strBuffer = Input(LOF(intFile), #intFile)
  7.     Close intFile
  8.     intFile = FreeFile
  9.     Open FileTo For Output As #intFile
  10.     Print #intFile, strBuffer
  11.     Close intFile
  12. End Sub
  13.  
  14.  
Jul 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
6
by: Nad | last post by:
Hello, I need some help with this: I am trying to update some data using XmlTextWriter. I instantiate first and then do some validation and then copy data into the dataset. Finally I commit...
7
by: W. Van Hooste | last post by:
Hello, I'm writing a program to display somme values as nice X graphics for a special purpose. Under here is part of my main code and part of the code to gather the sample data. the sample data...
4
by: Keith-Earl | last post by:
I have been writing ASP.NET apps since the RTM build and have never seen this. I built a simple app that uses session variables on my DEV laptop. All runs well. I have a simple toggle routine...
5
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the...
9
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
5
by: Andy | last post by:
Hello All: I am importing an Excel / CSV file. The problem I am having is: the columns are being defined for me as int32 (able to determine by using the ..GetFieldType method). As a result: ...
0
by: itrdbg | last post by:
I am programming to generate keys using different schemes for which i call different funtions and append data into a text file. At the end I am supposed to generat around 24320 bytes of data but end...
5
by: bgold12 | last post by:
When a user logs onto my site, I set some session data using php: .... session_start(); .... $_SESSION = 'value'; .... From what I understand, this should store the session data (i.e. the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.