Solved

Do you know...?

Posted on 2002-06-19
12
141 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 142

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 142

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
 
LVL 69

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 6

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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 69

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 142

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 69

Accepted Solution

by:
Éric Moreau earned 50 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now