|
-
Nov 15th, 2000, 04:37 PM
#1
Thread Starter
Lively Member
I posted this question before and got some help, but there
is just one thing that's giving me a BIG problem, and that
is... the form will not scroll!!!
The problem is that data at the bottom is not scrolled into
view. How do i achieve this ?
I would prefer to display the data on a form and not a DBGrid
p.s. How do I post the code like others with colours &
indent ?
here is the code....
Sub Scroll()
Dim vPos As Integer
Me.Cls
FontSize = 8
x = CurrentX
y = CurrentY
CurrentX = 300
CurrentY = y
For vPos = m_intLastPos To 100
While Not rst.EOF
Print rst!recno
CurrentY = y
CurrentX = 1600
Print rst!ItemNum
CurrentY = y
CurrentX = 3100
Print Format(rst!QtyRecvd, "###,##0")
CurrentY = y
CurrentX = 4600
Print rst!Descrip
CurrentY = y
CurrentX = 8100
Print Format(rst!unitprice, "##,###,##0.00")
CurrentY = y
CurrentX = 9600
value = rst!QtyRecvd * rst!unitprice
runtot = runtot + value
Print Format(value, "##,###,##0.00")
y = CurrentY
CurrentX = 300
rst.MoveNext
Wend
Next
m_intLastPos = VScroll1.value
' print total at end of report
If runtot > 0 Then
FontBold = True
FontUnderline = True
CurrentX = 8100
CurrentY = CurrentY + 500
y = CurrentY
Print "GRAND TOTAL"
CurrentX = 9600
CurrentY = y
Print Format(runtot, "##,###,##0.00")
FontBold = False
FontUnderline = False
Else
NothingFound
End If
Else
NothingFound
End If
End Sub
-
Nov 15th, 2000, 04:47 PM
#2
Too scroll a Form, use the following code. Add an HScroll and a VScroll.
Code:
Dim VPos As Integer
Dim HPos As Integer
Private Sub Form_Load()
'Change the following numbers to the Full height and width of your Form
intFullHeight = 8000
intFullWidth = 8000
'This is the how much of your Form is displayed
intDisplayHeight = Me.Height
intDisplayWidth = Me.Width
With VScroll1
.Height = Me.ScaleHeight
.Min = 0
.Max = intFullHeight - intDisplayHeight
.SmallChange = Screen.TwipsPerPixelX * 10
.LargeChange = .SmallChange
End With
With HScroll1
.Width = Me.ScaleWidth
.Min = 0
.Max = intFullWidth - intDisplayWidth
.SmallChange = Screen.TwipsPerPixelX * 10
.LargeChange = .SmallChange
End With
End Sub
Sub ScrollForm(Direction As Byte)
Dim CTL As Control
'Scroll Vertically
If Direction = 0 Then
For Each CTL In Me.Controls
'Make sure it's not a ScrollBar
If Not (TypeOf CTL Is VScrollBar) And Not (TypeOf CTL Is HScrollBar) Then
'If it's a Line then
If TypeOf CTL Is Line Then
CTL.Y1 = CTL.Y1 + VPos - VScroll1.Value
CTL.Y2 = CTL.Y2 + VPos - VScroll1.Value
Else
CTL.Top = CTL.Top + VPos - VScroll1.Value
End If
End If
Next
VPos = VScroll1.Value
Else
'Scroll Horizontally
For Each CTL In Me.Controls
'Make sure it's not a ScrollBar
If Not (TypeOf CTL Is VScrollBar) And Not (TypeOf CTL Is HScrollBar) Then
'If it's a Line then
If TypeOf CTL Is Line Then
CTL.X1 = CTL.X1 + HPos - HScroll1.Value
CTL.X2 = CTL.X2 + HPos - HScroll1.Value
Else
CTL.Left = CTL.Left + HPos - HScroll1.Value
End If
End If
Next
HPos = HScroll1.Value
End If
End Sub
Private Sub HScroll1_Change()
ScrollForm 1
End Sub
Private Sub HScroll1_Scroll()
ScrollForm 1
End Sub
Private Sub VScroll1_Change()
ScrollForm 0
End Sub
Private Sub VScroll1_Scroll()
ScrollForm 0
End Sub
To make your code in colours, inclose it in code brackets.
[code]
MyCodeHere
[/code]
-
Nov 15th, 2000, 06:27 PM
#3
Thread Starter
Lively Member
Thanks for your quick reply Megatron, but I already have
something similar to that....
This is what I have
[code]
Private Sub Form_Load()
frmPrtToScr.BackColor = &HFFFFFF
VScroll1.Max = 100
VScroll1.LargeChange = 5
VScroll1.SmallChange = 1
runtot = 0
If frmPrtOptions.optPrt.value = True Then
PrtReport
ElseIf frmPrtOptions.optScr.value = True Then
Call Scroll
End If
End Sub
Private Sub Form_Resize()
With VScroll1
.Top = 0
.Height = ScaleHeight
.Left = ScaleWidth - .Width
End With
End Sub
Private Sub VScroll1_Change()
Call Scroll
End Sub
Private Sub VScroll1_KeyUp(KeyCode As Integer, Shift As Integer)
Call Scroll
End Sub
Private Sub VScroll1_KeyDown(KeyCode As Integer, Shift As Integer)
Call Scroll
End Sub
Sub Scroll()
Dim vPos As Integer
Me.Cls
FontSize = 8
x = CurrentX
y = CurrentY
CurrentX = 300
CurrentY = y
rst.MoveFirst
If blank = False Then
For vPos = m_intLastPos To 100
While Not rst.EOF
Print rst!recno
CurrentY = y
CurrentX = 1600
Print rst!ItemNum
CurrentY = y
CurrentX = 3100
Print Format(rst!QtyRecvd, "###,##0")
CurrentY = y
CurrentX = 4600
Print rst!Descrip
CurrentY = y
CurrentX = 8100
Print Format(rst!unitprice, "##,###,##0.00")
CurrentY = y
CurrentX = 9600
value = rst!QtyRecvd * rst!unitprice
runtot = runtot + value
Print Format(value, "##,###,##0.00")
y = CurrentY
CurrentX = 300
rst.MoveNext
Wend
Next
'print report total
If runtot > 0 Then
FontBold = True
FontUnderline = True
CurrentX = 8100
CurrentY = CurrentY + 500
y = CurrentY
Print "GRAND TOTAL"
CurrentX = 9600
CurrentY = y
Print Format(runtot, "##,###,##0.00")
FontBold = False
FontUnderline = False
Else
NothingFound
End If
Else
NothingFound
End If
m_intLastPos = VScroll1.value
End Sub
[Edited by yenni on 11-15-2000 at 06:41 PM]
-
Nov 15th, 2000, 09:40 PM
#4
Hyperactive Member
Cant you just make everything you want to scroll in a frame, and then put to the scroll event of the scrollbar something like this:
frame1.top = 0 - vscroll1.value
When min of vscroll1 is 0 and max is the height of the frame.
Just a suggestion, may not work...
-JR-
-
Nov 15th, 2000, 09:47 PM
#5
Addicted Member
So how do you post code so it looks correct in the forums?
Shawn Hull
VB6, SP3 (Professional Edition)
-
Nov 15th, 2000, 10:06 PM
#6
Hyperactive Member
-
Nov 16th, 2000, 05:44 PM
#7
Thread Starter
Lively Member
If I use a frame, will I be able to scroll the frame so the
text at the bottom will come into view?
-
Nov 16th, 2000, 06:47 PM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|