Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Combo box question

Status
Not open for further replies.

Newatprogramming

Technical User
Mar 5, 2002
30
0
0
US
I am setting up a form page setup. The form has a tabstrip (margin/paper). On the Tab paper I want to put a combo box to allow the user to specify either letter/legal size. I can get it to do this part, but I also want it to show in (2) text boxes the width and height of the paper size chosen. Here is what I did. I assume I am writing the second portion in the wrong procedure? Any help would be great.

Private Sub Form_Load()
cboPageSetup.AddItem "Letter"
cboPageSetup.AddItem "Legal"
End Sub

' this below part appears to do nothing

Private Sub cboPageSetup_Change()
If cboPageSetup.AddItem = "Letter" Then
txtHeight.Text = 11
txtWidth.Text = 8.5
End If
If cboPageSetup.AddItem = Legal Then
txtHeight.Text = 14
txtWidth.Text = 8.5
End If
End Sub
 
You might try using the Click event of the Combo Box instead of the Change event.
 

Perfect Thank You. Though I have developed a new problem. This does not actually change my printer papersize? I am using an If statement to no when to Printer.NewPage

' Thanks for this help!!!
Private Sub cboPageSetup_Click()

If cboPageSetup = "Letter" Then
txtHeight.Text = 11
txtWidth.Text = 8.5
End If
If cboPageSetup = "Legal" Then
txtHeight.Text = 14
txtWidth.Text = 8.5
End If
End Sub

' here is my current test
If Printer.CurrentY >= frmPrint.txtHeight - _
frmPrint.lblMarginBottom - frmPrint.lblMarginTop Then
Printer.NewPage
PrintPageTitle
psngLastY = Printer.CurrentY
End If

! It works great if I do not change my paper size in my print form to Legal 14 x 8.5


Any ideas????

 

From VB's Help file...
[tt]
Height, Width Properties


Return or set the dimensions of an object or the width of the Columns object of a DataGrid control. For the Printer and Screen objects, not available at design time.

Syntax

object.Height [= number]

object.Width [= number]

The Height and Width property syntaxes have these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
number A numeric expression specifying the dimensions of an object, as described in Settings.


Settings

Measurements are calculated as follows:

Form — the external height and width of the form, including the borders and title bar.


Control — measured from the center of the control's border so that controls with different border widths align correctly. These properties use the scale units of a control's container.


Printer object — the physical dimensions of the paper set up for the printing device; not available at design time. If set at run time, values in these properties are used instead of the setting of the PaperSize property.


Screen object — the height and width of the screen; not available at design time and read-only at run time.


Picture object — the height and width of the picture in HiMetric units.
Remarks

For Form, Printer, and Screen objects, these properties are always measured in twips. For a form or control, the values for these properties change as the object is sized by the user or by your code. Maximum limits of these properties for all objects are system-dependent.

If you set the Height and Width properties for a printer driver that doesn't allow these properties to be set, no error occurs and the size of the paper remains as it was. If you set Height and Width for a printer driver that allows only certain values to be specified, no error occurs and the property is set to whatever the driver allows. For example, you could set Height to 150 and the driver would set it to 144.

Use the Height, Width, Left, and Top properties for operations or calculations based on an object's total area, such as sizing or moving the object. Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations or calculations based on an object's internal area, such as drawing or moving objects within another object.

Note The Height property can't be changed for the DriveListBox control or for the ComboBox control, whose Style property setting is 0 (Dropdown Combo) or 2 (Dropdown List).

For the Columns object of the DataGrid control, Width is specified in the unit of measure of the object that contains the DataGrid. The default value for Width is the value of the DefColWidth property of DataGrid.

For the Picture object, use the ScaleX and ScaleY methods to convert HiMetric units into the scale you need
[/tt]

so in short you would need to do...
[tt]
Printer.Height = 14 * 1440 '1440 twips per inch
[/tt]
that is if the printer supports this property...


Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top