Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 22nd, 2014, 11:12 AM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Display a string on a Form

I converted an old VB 6 program to VB 2008. What the program does is to read a database table and depending on data requirements, it is supposed to display the record like first name and last name on to the form. With VB 6.0 I just used the print method currentx and currenty but with VB 2008 I can't get them to print. I have searched around and saw CreateGraphics so I used it to replace the print statement from VB 6.0. After doing this, I can only see a blank form and the records are not getting displayed.

Below is the original VB 6.0 code.

Private Sub PrintHeading(strstring, intColumn, introw, fontsize)
frmPrintBenefits.Height = 15000
frmPrintBenefits.Width = 11500
frmPrintBenefits.CurrentX = intColumn
frmPrintBenefits.CurrentY = introw
frmPrintBenefits.fontsize = fontsize
frmPrintBenefits.FontBold = True
frmPrintBenefits.Print strstring
End Sub
Here is the code from VB 2008 after it was converted. I used drawstring to print or display the records on the form. I thought this would work but I am seeing a blank form.

Friend Class frmPrintBenefits
   Inherits System.Windows.Forms.Form
   Dim g As Graphics = Me.CreateGraphics
   Dim strstring as String
   Dim intColumn as Integer
   Dim intRow as Integer
   Dim fontsize as Double
   Private Sub PrintHeading(ByRef strstring As String, ByRef intColumn AsInteger, ByRef introw AsInteger, ByRef fontsize As Integer)
   Me.Height = VB6.TwipsToPixelsY(15000)
   Me.Width = VB6.TwipsToPixelsX(11500)
   Me.Font = VB6.FontChangeSize(Me.Font, fontsize)
   Me.Font = VB6.FontChangeBold(Me.Font, True)
   g.DrawString(strstring, Font, Brushes.Black, intColumn, introw)
   End Sub
End Class
Am I using the wrong syntax?


Last edited by jmss66; April 22nd, 2014 at 11:21 AM..
Reply With Quote
  #2 (permalink)  
Old April 22nd, 2014, 03:49 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts

If you don't *have* to draw, but just want to output the text, you can also add a Label to the form and assign text to it.

To add the Label, just drag one from the Toolbox. Then you can assign text to it like this:

label1.Text = "Whatever you want"

Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Data Will Not Display When I Click On Display Button sprdave BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 12 February 13th, 2011 12:09 AM
Display the Length of the String kulfi BOOK: Beginning Microsoft Visual Basic 2010 15 December 30th, 2010 04:41 PM
Display String value for given period cloudsuser JSP Basics 1 June 25th, 2010 11:28 PM
Display attribute and particular string in different color rangeshram XSLT 1 October 30th, 2009 06:49 PM
Display 0 currency as Null String echovue Access 5 August 11th, 2005 02:33 PM

All times are GMT -4. The time now is 07:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.