Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-08-05 : 12:57:42
|
hello professional,how days r going onhere is another problem for u guysi am printing a Table ..... in such a manner Printer.Print Space(10); "Items of Import:-"Printer.FontBold = FalsePrinter.Print Space(10); "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Printer.Print Space(15); "Sr"; Space(5); "Description"; Space(5); "Generic"; Space(5); "Unit Price"; Space(5); "Quantity"; Space(5); "Unit of Quantity"; Space(5); "Accessories,if any"; Space(5); " Manufacter's Name"; Space(5); "Brand"; Space(5); "Model Specifications"Printer.Print Space(10); "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"; Space(10)Cs.CommandText = "select Item_No,Item_Description,Generic_Description,Unit_Price,Quantity,Unit_Of_Quantity,Accessaries,Manufacter_Name,Brand,Model_Specification from Fourthbe Where Be_Id='" + BeNo + "'"Cs.ExecuteWith Cs.ExecuteDo While Not .EOFPrinter.Print Space(15); "" + .Fields(0) + ""; Space(5); "" + .Fields(1) + ""; Space(8); "" + .Fields(2) + ""; Space(8); "" + .Fields(3) + ""; Space(8); "" + .Fields(4) + ""; Space(8); "" + .Fields(5) + ""; Space(8); "" + .Fields(6) + ""; Space(8); "" + .Fields(7) + ""; Space(8); "" + .Fields(8) + ""; Space(8); "" + .Fields(9) + ""Printer.Print.MoveNextLoopEnd Withit does not print grid like structure, here the length of each fields may vary, they have sometimes full length value or some times no values how alligned this gridsome of you suggest me left(value1+space(100),100) but sorry to say those this technique doesn't workor i am wrongplease correct my Format Stringamit kumar madhukar |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-08-05 : 13:17:39
|
why don't you show us how you tried to implement that suggestion? Because it DOES work, but it may not if you didn't implement it correctly or understand the what that particular technique is trying to accomplish.- Jeff |
|
|
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-08-06 : 05:26:30
|
if i don't know or don't implement the coding in better way then please give me the appropriate way i am very thankful to youamit kumar madhukar |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-08-06 : 08:48:11
|
let's say you want to print 3 columns:Name, Date, AgeName will be 40 characters long, justified left.Date will be in the mm/dd/yyyy format, so that's 10 characters, justified right.Age will be only 3 characters long, also justified right.Between each column you will have 2 spaces.First, then, print your headings. Print each word to describe the heading, then as many spaces as you need to be sure things line up:print "Name" & space(40 - 4 + 2) & space(10-4) & "Date" & space(2) & "Age" NOtice i did some math (use the results, not the formula, in your code). For the first column (Name) we want the column to be 40 characters long (40), so we need to add (40-4) spaces after the word "Name" since that word is 4 characters long. Then we need 2 spaces (+2) afterwards.For the Date column, we want it right justified, so we put the spaces BEFORE the word, and then the 2 spaces after. for the "Age" column, no special tricks are needed.Does this make sense? Stop reading here if you are not following, and go over it until it becomes clear.Now we do the same for your data. We need to pad each field with spaces before or after it so that it is wide enough for the column, then add 2 spaces afterwards.To pad spaces to the variable X so that it is exactly 40 characters long, how can we do that? Well, we need to add (40-(Length of X)) spaces to it -- either before it or after, depending on whether it is right aligned or left aligned. Makes sense?(note: you can also say: Left(x & space(40),40) or Right(space(40) & x,40) to do the same thing -- does this make sense? try it out, do some testing, see why it works.)so, here we go, for each line:print Name & space(40 - Len(Name) + 2) & space(10-len(Date)) & DAte & space(2) & space(3-len(age)) & Age Does this help?- Jeff |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-08-06 : 10:55:06
|
Good post, Jeff. I think another problem that might be complicating the issue here is the font he's using. Amit, if you want all values aligned exactly, then you need to use a mono-spaced font for the report data, such as Courier or Lucida. Other fonts have varying widths for each character and that makes it nearly impossible to align the values consistently.OS |
|
|
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-08-06 : 17:02:55
|
Sorry Jsmith it does not solving my problemlook again what u give me suggestion if far away from my questionlook i a three columnsnamed, Sr Number,Item Description,AmountDescription of Each Columns areSr=Varchar(2),Item Description Varchar(30), and Amount double type varibalenow i use to print in certain loopsassume i execute three time loopin first loop the actual length of my recordset with each columns as:[sr]-(1),[Item Description]-21,[Amount]-8in second loop , it becomes now[sr]-(1),[Item Description]-15,[Amount]-8in third and final round it becomes[sr]-(1),[Item Description]-26,[Amount]-8thus my output looks like1--Item Description------452636.521--Item Description---452636.521--Item Description----------452636.52but i want printing looks like wheather the length or varibale may change in each iteration example :Invoice Printing where startline of each coloumns are exact linear1--Item Description------452636.521--Item Description------452636.521--Item Description------452636.52can u help me now with better wayamit kumar madhukar |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-08-06 : 17:39:23
|
Please re-read my post! you are not even trying to understand the advice given. What part of my post have you tried specifically? And please stop posting this same question as new topics.Show us exactly how you tried to make use of the advice i gave you.- Jeff |
|
|
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-08-07 : 02:46:16
|
sir, i use ur suggestion in this wayPrinter.PaperSize = vbPRPSA4Printer.Orientation = vbPRORPortraitPrinter.PaperSize = vbPRPSA4Printer.Font = "Courier" 'Lucida/CourierPrinter.FontSize = 10Cs.CommandText = "select Item_Description,Generic_Description,Item _Code from BL"Cs.ExecuteWith Cs.ExecuteDo Until .EOFPrinter.Print .Fields(2) & Space(30 - Len(.Fields(2)) + 5) & Space(30 - Len(.Fields(3))) & .Fields(3).MoveNextLoopPrinter.EndDocEnd Withwhere Item_Description's length =30,Item_Description's length =30, andItem_Code's length =10where total length ofamit kumar madhukar |
|
|
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-08-07 : 09:49:34
|
JSmith Sir ,Thanks for good suggestionshowever ur does not works,but yet i get my way to solve the problem and i think that ur suggestion without the suggestion of mohodiwas from UAE is worthless,however mohodiwas not courier but Courier New is the right font thanks u bothJsmith ur suggestion does not work fully but it is very near to the solutionsthanks againamit kumar madhukar |
|
|
|
|
|
|
|