Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Do you know...?

Posted on 2002-06-19
12
Medium Priority
?
149 Views
Last Modified: 2010-05-02
Dim fs As Object, a As Object, i As Integer
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile(App.Path "\printfile.txt",True)
   
    For i = 1 To currow - 1
        a.writeline ("   " & soldlist.TextMatrix(i, 1) & " " & soldlist.TextMatrix(i, 2) & "                    " & soldlist.TextMatrix(i, 3) & "       " & soldlist.TextMatrix(i, 4) & "       " & soldlist.TextMatrix(i, 5))
       
    Next i
        a.writeline ("                                   " & soldlist.TextMatrix(9, 5))
    a.Close

   Here I want function to print the column in a formate ,becuz while I am trying to print like thise its alignment is changing depends on the lengthe of the words

  advanced thanks for answering experts.......
0
Comment
Question by:romance
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7092343
I would use the vbtab instead of the "      ":

a.writeline (vbtab & soldlist.TextMatrix(i, 1) & vbtab & soldlist.TextMatrix(i, 2) & vbtab & soldlist.TextMatrix(i, 3) & vbtab & soldlist.TextMatrix(i, 4) & vbtab & soldlist.TextMatrix(i, 5))

CHeers
0
 

Author Comment

by:romance
ID: 7092378
1025     Lipstics (G) Nike 2 ML          15.00     1.00 15.00
1027     SHIRT (G)  KOLLAR SHANFA 1 1/2 INCH           68.00     2.00     136.00

   here second column "shirt(g) kollar shanfa 1 1/2 inch" is too long , then its taking the space of third column , how can I arrange it.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7092387
The problem is that either you write with vbtab to delimit, or you have to write as many spaces (knowing the max size of each column.

Say you know the size of column 1 is 10, then:
a.writeline (right(string(11," ") &(soldlist.TextMatrix(i, 1), 11)  ...
This right-aligns the ID values...

then for second column, say max = 50, and left-aligned:
 ... & left(soldlist.TextMatrix(i, 2) & string(51, " "), 51)  ...

CHeers
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7092402
You can create a fixed width this way:

a.writeline ("   " & _
  left(soldlist.TextMatrix(i, 1) + space(10),10) & " " & _
  left(soldlist.TextMatrix(i, 2) + space(20),20) & " " & _
  left(soldlist.TextMatrix(i, 3) + space(50),50) & "       " & _
  left(soldlist.TextMatrix(i, 4) + space(10),10) & "       " & _
  left(soldlist.TextMatrix(i, 5) + space(10),10))
0
 
LVL 11

Expert Comment

by:Nitin Sontakke
ID: 7092574
Needless to say this, but make sure you are seeing the text file in a correct font as well, say "Courier New", for example.
0
 
LVL 1

Expert Comment

by:olx
ID: 7093136
use the msflexgrid

'----- to add the info to the grid:

'build the info
t = "1025" & vbtab & "Lipstics (G) Nike 2 ML" & vbtab & "15.00" & "1.00" & "15.00"
'to save later that info..
Target = Target & t & vbcrlf

'add it to the grid
me.msflexgrid1.additem t

'----- to save the info to excel.

open "target.xls" for binary as #1
x = string(len(target)," ")
x = target
put #1,1,x
close 1

shell "start target.xls"

'--------
'if you have more than 2000 records... at the time to save to excel it will take more and more time to save it... it is fast, but if you use this other code it will take so less time youll get surprised...

'instead of:
Target = Target & t & vbcrlf

'use
if inspos = 0 then inspos = 1
If InsPos + Len(t & vbcrlf) > Len(target) Then target = target & Space$(10000)
Mid(target, InsPos, Len(t & vbcrlf)) = t & vbcrlf
InsPos& = InsPos& + Len(t & vbcrlf)
           

hope this helps.-
0
 

Author Comment

by:romance
ID: 7097901
Dim fs As Object, a As Object, i As Integer
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile(App.Path & "\printfile.txt", True)
   
    For i = 1 To currow - 1
        a.writeline (vbTab & soldlist.TextMatrix(i, 1) & vbTab & Left(soldlist.TextMatrix(i, 2) + Space(30), 30) & vbTab & Left(soldlist.TextMatrix(i, 3) + Space(8), 8) & vbTab & Left(soldlist.TextMatrix(i, 4) + Space(6), 6) & vbTab & Left(soldlist.TextMatrix(i, 5) + Space(8), 8))
    Next i

   here I got the alingment , but still there is a problem
 I can't aling the number to right
 
  1020 liptstic 10 ml    45.00    1.00    45.00
  1026 body spray 100ml  450.00   2.00    450.00
   how can I align these ...
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7098320
For numeric fields, pad the number to the right like this:

...& right(Space(8) + soldlist.TextMatrix(i, 5), 8))
0
 

Author Comment

by:romance
ID: 7098628
but it disappears  that particular column , if we are using the right function
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7098631
Please note that you need to write having this order:
right ( space(n) & text, n)
and
left (  text & space(n), n)

CHeers
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 7098637
like angelIII told, you need to add spaces before your value (not after).
0
 

Author Comment

by:romance
ID: 7100130
yes, yes emoreau is right , I am sorry its working ,
thanks
 
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question