Results 1 to 13 of 13

Thread: Can't make the picturebox wide enough?

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Can't make the picturebox wide enough?

    Hi there folks!

    I am working on a number line to teach kids how to skip count numbers. So basically I have a numberline in a picturebox called picPicture. That one is inside another picturebox called picWindow (I got this code off here). : )

    So the picturebox scrolls, but the problems is I can't scroll as far as I want.

    The number line image file goes from 0-100. The box will only let me scroll up to 39(ish).

    Would anyone know of a way to make it scroll to 100?

    Thanks!

    Here is my code.

    VB Code:
    1. Option Explicit
    2.  
    3. ' You have a royalty-free right to use, modify, reproduce and distribute
    4. ' the Sample Application Files (and/or any modified version) in any way
    5. ' you find useful, provided that you agree that Martin Liss has no warranty,
    6. ' obligations or liability for any Sample Application Files.
    7.  
    8.  
    9.  
    10.  
    11.  
    12. Private Sub Form_Activate()
    13.  
    14.     ' So that scrooling will happen if the user immediately presses
    15.     ' PageUp or PageDown
    16.     picPicture.SetFocus
    17.    
    18. End Sub
    19.  
    20. Private Sub Form_Load()
    21.  
    22.  
    23.     HScroll1.Width = picWindow.Width
    24.  
    25.    ' HScroll1.Max = picPicture.Width - picWindow.Width
    26.  
    27.    
    28.     HScroll1.SmallChange = 200
    29.    
    30.     HScroll1.LargeChange = picWindow.Width
    31.    
    32.     If picPicture.Picture = 0 Then
    33.         lblNoPicture.Visible = True
    34.         lblNoPicture.Caption = "Change picPicture's Picture property to refer " _
    35.                              & "to the location of winnt.bmp (or any large picture)"
    36.     End If
    37.    
    38. End Sub
    39.  
    40.  
    41. Public Sub CheckKeyCode(KeyCode As Integer)
    42. '***************************************************************************
    43. 'Purpose: Intercept and act on special keys on me so
    44. '         that up and down arrows and scroll bar works as expected. Also
    45. '         automatically scroll screen when Tab key would otherwise disappear
    46. '         off the screen.
    47. 'Inputs:  KeyCode - The ASCII(?) value of the key pressed
    48. 'Outputs: None
    49. '***************************************************************************
    50.  
    51.     Dim nScrollValue As Double
    52.     Dim nOnePage As Integer
    53.    
    54.     nOnePage = Me.VScroll1.Height
    55.    
    56.     If KeyCode = vbKeyPageUp Or KeyCode = vbKeyPageDown Then
    57.         If KeyCode = vbKeyPageDown Then
    58.             nScrollValue = -Me.picPicture.Top + nOnePage
    59.         Else
    60.             nScrollValue = -Me.picPicture.Top - nOnePage
    61.         End If
    62.         'Make sure that the scroll bar 'handle' is not attempted to be positioned
    63.         'below the bottom of the scroll bar.
    64.         If nScrollValue > Me.VScroll1.Max Then
    65.             nScrollValue = Me.VScroll1.Max
    66.             Me.picPicture.Top = -Me.VScroll1.Max
    67.         End If
    68.         If nScrollValue > 0 Then
    69.             Me.VScroll1.Value = nScrollValue
    70.         Else
    71.             Me.VScroll1.Value = 0
    72.         End If
    73.     End If
    74.    
    75. End Sub
    76.  
    77. Private Sub HScroll1_Change()
    78.  
    79.     picPicture.Left = -(HScroll1.Value)
    80.  
    81. End Sub
    82.  
    83. Private Sub picPicture_KeyDown(KeyCode As Integer, Shift As Integer)
    84.  
    85.     CheckKeyCode KeyCode
    86.    
    87. End Sub
    88.  
    89. Private Sub ExitButton_Click()
    90. Unload Me
    91. End Sub
    Last edited by Justin M; Oct 18th, 2015 at 10:17 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width