Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Printing characters


Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2009, 05:46 AM
babyboyx babyboyx is offline
Newcomer
 
Join Date: Jun 2009
Posts: 1
Default Printing characters


$++++++++++
$$+++++++++
$$$++++++++
$$$$+++++++
$$$$$++++++
$$$$$$+++++
$$$$$$$++++
$$$$$$$$+++
$$$$$$$$$++
$$$$$$$$$$+

wad the code for this if i wanna print it out in a picbox
by using for next loop ??
teach me pls
Reply With Quote
  #2  
Old 06-06-2009, 09:48 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 5,877
Default

Welcome to the forum X, Do not forget to read the forum Posting Guidelines.

Regarding your question,

Define and Break your problem down.
Your end result is a block of text 11 columns wide by 10 cows tall.

You could just write each line verbatim to the picturebox with the Picture1.Print <Text> method but you wouldn't learn much about loops or variables.

The For..Next loop will allow you to loop for a given number of iterations. Say perhaps for the number of rows you want to write.

As far as the contents of each line goes an easy way to handle the problem would be to use two string variables. One for the Dollar signs the other for the Plus signs.
On each interation of the loop increase one and decrease the other. Print the combined result.

To follow good programming practice you wouid want to write this as a procedure that could take a picturebox, any two characters and any number of rows to print.

Something like this,

Code:
Private Sub Command1_Click() ' Draw a pattern DrawTextBlock Picture1, "A", "B", 6 msgbox "Press OK to continue DrawTextBlock Picture1, "X", "O", 4 msgbox "Press OK to continue DrawTextBlock Picture1, "9", "6", 12 End Sub Private Sub DrawTextBlock(ByRef Pic As PictureBox, _ ByVal Char1 As String, ByVal Char2 As String, _ ByVal Rows As Integer) 'Uses the string(<Count>,<Character>) Function Dim myText As String ' Temporary holder (Makes code clearer) Dim n As Integer ' counter Pic.Cls 'Clear the picturebox For n = 1 To Rows ' Build a string variable ' (We add one to rows before subtraction so at the last pass ' through the loop it's count will be 1.) myText = String(n, Char1) & String(Rows + 1 - n, Char2) 'Print myText to the picturebox and move the text cursor down one line. Pic.Print myText Next n End Sub
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 06-07-2009 at 10:57 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->