Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorry, leading zeroes again :-(( | Excel Discussion (Misc queries) | |||
Leading Zeroes | Excel Discussion (Misc queries) | |||
Leading Zeroes | Excel Discussion (Misc queries) | |||
No decimals and leading zeroes | Excel Discussion (Misc queries) | |||
CSV leading zeroes | Excel Discussion (Misc queries) |