Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ww ww is offline
external usenet poster
 
Posts: 6
Default Print# Statement | Leading zeroes

Hello

I am using the Print Statement to create a comma separated, quotes
file.

One of the data is a value with a leading zero "0234".

I have tracked its "print" to the OpenFile and it appears to print and
exist as "0234" until the Close# Command. Debug.Print shows the datum
to remain "0234" until the Close command which automatically converts
it to "0". :-/

I am looking for ways to Print "0233" without it being interpreted as
a number. i have included a portion of the code below which has been
modified from the Knowledge Base solution for CommaQuotes files:

For RowCount = 1 To UBound(TheArray, 1)

' Loop for each column in selection.
For ColumnCount = 1 To UBound(TheArray, 2)
sVal = Format(TheArray(RowCount, ColumnCount), "")
' Write current cell's text to file with quotation
marks.
Print #FileNum, """" & sVal & """";

' Check if cell is in last column.
If ColumnCount = UBound(TheArray, 2) Then
' If so, then write a blank line.
Print #FileNum,
Else
' Otherwise, write a comma.
Print #FileNum, ",";
End If
' Start next iteration of ColumnCount loop.
Next ColumnCount
' Start next iteration of RowCount loop.
Next RowCount

' Close destination file.
Close #FileNum
End Sub

Thanks in advance.

W
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print# Statement | Leading zeroes

The place to look is in the file itself. In the file is it written as
,"0234",
Sub Tester2()

Open "C:\Data\AAtext.Txt" For Output As #1
sVal = "0123"
Print #1, """" & sVal & """"
sVal = "0223"
Print #1, """" & sVal & """"
sVal = "0333"
Print #1, """" & sVal & """"
Close #1

End Sub

produced:

"0123"
"0223"
"0333"

--
Regards,
Tom Ogilvy


"ww" wrote in message
om...
Hello

I am using the Print Statement to create a comma separated, quotes
file.

One of the data is a value with a leading zero "0234".

I have tracked its "print" to the OpenFile and it appears to print and
exist as "0234" until the Close# Command. Debug.Print shows the datum
to remain "0234" until the Close command which automatically converts
it to "0". :-/

I am looking for ways to Print "0233" without it being interpreted as
a number. i have included a portion of the code below which has been
modified from the Knowledge Base solution for CommaQuotes files:

For RowCount = 1 To UBound(TheArray, 1)

' Loop for each column in selection.
For ColumnCount = 1 To UBound(TheArray, 2)
sVal = Format(TheArray(RowCount, ColumnCount), "")
' Write current cell's text to file with quotation
marks.
Print #FileNum, """" & sVal & """";

' Check if cell is in last column.
If ColumnCount = UBound(TheArray, 2) Then
' If so, then write a blank line.
Print #FileNum,
Else
' Otherwise, write a comma.
Print #FileNum, ",";
End If
' Start next iteration of ColumnCount loop.
Next ColumnCount
' Start next iteration of RowCount loop.
Next RowCount

' Close destination file.
Close #FileNum
End Sub

Thanks in advance.

W



  #3   Report Post  
Posted to microsoft.public.excel.programming
WW WW is offline
external usenet poster
 
Posts: 4
Default Print# Statement | Leading zeroes


Tom, thank you.

The Format command was corrupting the pure value of the record.

WW

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry, leading zeroes again :-(( Argghhhh Excel Discussion (Misc queries) 7 November 13th 06 10:26 PM
Leading Zeroes Melissa Excel Discussion (Misc queries) 3 October 11th 06 07:38 PM
Leading Zeroes Ken Excel Discussion (Misc queries) 1 October 7th 05 03:17 PM
No decimals and leading zeroes gcotterl Excel Discussion (Misc queries) 2 April 18th 05 06:50 AM
CSV leading zeroes Tim_nol Excel Discussion (Misc queries) 2 December 28th 04 08:19 PM


All times are GMT +1. The time now is 09:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"