i have one form, with 2 picture boxes, one Vscroll, and so many textboxes in pictureboxes..
when i m clicking the VScroll, it works...
now i want that when i press enter button in textbox the scroll should go down, as it goes on click.please help me.

to change VScroll1 value i think this will help you !

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If Not VScroll1.Value = VScroll1.Min Then    'if minimum then stops
        VScroll1.Value = VScroll1.Value - 10
    End If
End If
End Sub

please note that it never cross minimum and maximum values...

Edited 5 Years Ago by Vineeth K: n/a

this code is not working...
performing no any action....
and i told u, i have two picture boxes, one is inner, and second is outer, the outer is inside the inner pic box, and i have kept 40 textboxes inside the outer pic box, now i have hiden 45 text boxes by consuming the size of inner pic box, now when i run the program only 5 text boxes are shown up, when i m clicking the Vscroll, other are come to show,,,,now i want when i press enter button in textbox 5, the VSCroll show go down to text box 6 as it goes when i click on it, now it should perform on key...

i can't understand what are you trying to do, sorry, may be post an image.
I guess you have a big page to display and only few of them comes to screen.. may be use a mdi form and increase your forms size, width and height.Remove its border, the mdi form will automatically add scroll bars if the forms size is big.
or if you want to move down the picture box with text and then add code in your vscroll to move your picture box when its value changed...
this one is not complete but may be it will help you

Dim tempH As Integer
Private Sub Form_Load()
VScroll1.Max = 8535 'the frame height
VScroll1.Min = 0
VScroll1.Value = Frame1.Height
tempH = Frame1.Top
End Sub

Private Sub VScroll1_Change()
Frame1.Height = VScroll1.Value
Frame1.Top = tempH
End Sub

Edited 5 Years Ago by Vineeth K: n/a

Attachments my_mdi_form.jpg 41.1 KB

this is what i want...
now there is a form, VSCRoll, two pic boxes, there are two pic boxes, pic box 1 n 2..
i have kept pic box 2 inside the pic box 1. and 15 text boxes inside the pic box 2.
now i have shown down only 6 text boxes, and rest are hidden, when i m clicking on VScroll, others are coming up..i want to do that with keypress.

If you used the code as per your previous thread, the following should work -

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If Not VScroll1.Value = VScroll1.Min Then    'if minimum then stops
        pbInner.Left = -HScroll1.Value
        pbInner.Top = -VScroll1.Value
    End If
End If
End Sub

this code is not working...i have already tried this....
this is what, i have used this code..

1.Private Sub Form_Load()
2.VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight
3.pbOuter.Move 0, 2000

4.VScroll1.Max = pbInner.Height - pbOuter.Height
5.VScroll1.LargeChange = 2500
6.VScroll1.SmallChange = 250
7.End If

8.End Sub

9.Private Sub VScroll1_Change()

10.pbInner.Top = 0 - VScroll1.Value

11.End Sub

I see, you do not have to scroll the picture box up by using the scroll bars, do it in normal code -

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 13 Then
    pbInner.Top = pbInner.Top - 50
End If
End Sub

or may be you are trying to do what we do in creating a game menu, normally it will show 3 or 4 buttons when you press down then it will display the rest of the hiding button,
here you are showing 6 textboxes and you want to show remaining when enter is pressed..
here may be this code will help .... here i have 6 text boxes only 4 shown
when you press enter if next textbox is not in the screen then it will be shown and the above one will hide and i used textboxes as an array for an easy work..
i posted sample vb project file down ....
here VScroll1 maximum value is 5 there are 6 texts in that array and minimum is 4 ..

Dim j As Integer
Private Sub Form_Load()
For i = 0 To 3
j = j + Text1(0).Height
Next
pic1.Height = j
VScroll1.Height = j
For i = 0 To 5
Text1(i).Top = i * Text1(0).Height
Next
For i = 0 To 5
Text1(i).Text = "Text Box " & i
Next
End Sub

Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
    VScroll1.Value = Index + 2
End If
End Sub

Private Sub VScroll1_Change()
Select Case VScroll1.Value
Case 4
For i = 0 To 5
Text1(i).Top = i * Text1(0).Height
Next
Case 5
For i = 0 To 5
Text1(i).Top = (0 - Text1(0).Height) + (i * Text1(0).Height)
Next
Case 6
For i = 0 To 5
Text1(i).Top = (0 - (Text1(0).Height * 2)) + (i * Text1(0).Height)
Next
Case 6
For i = 0 To 5
Text1(i).Top = (0 - (Text1(0).Height * 3)) + (i * Text1(0).Height)
Next
End Select
End Sub
Comments
Superb....Mind Blowing

this would'nt work brother...becoz it is gud when ve want to scroll up pbinner, and when we use to scroll down??? then?? there will be scroll bar used..or another way, in wch we can perform both operations, scroll up and scroll down.

this is what i wanted....can u explain this code plz????? and can't this code b short...becoz i have to use minimum 45 textboxes for each form, and i have atleast 10 forms...

HAPPY TO HEAR THIS ...... this code never increase anymore because i used an array text boxes so i can call all textboxes using an loop.
first i created text boxes in an array[in your case its better to use an array of textboxes], then i added all of them in that picture box and reduced its size and adjusted all textboxes using a loop. Then in VScroll1 value change event used a select case to compare the index, i want to show minimum 4 textboxes so i started selection from 4th index, then just adjust the positions of textboxes [it will increase each time when the index increases].
Then add code to change value of VScroll1 . i posted the source, i think you can work on that....
To reduce there are complicated ways,if you want to save space on your form1 its better to add codes to a module and call that and i used some repetitive loops[loop to get total height of all textboxes you can avoid that], codes you can avoid it ...

Edited 5 Years Ago by Vineeth K: n/a

ok thanks bro...can u tell me that how this code will work when i have more than one textboxes in a row...means how will more than one text boxes will go up...when i have 2 textboxes in a row, and i have two columns of text boxes.

i'm late ......
it need another array text boxes then add that text in that loop use the same code in text box key event.

Dim j As Integer
Private Sub Form_Load()
For i = 0 To 3
j = j + Text1(0).Height
Next
pic1.Height = j
VScroll1.Height = j
For i = 0 To 5
Text1(i).Top = i * Text1(0).Height
Text2(i).Top = i * Text1(0).Height
Next
For i = 0 To 5
Text1(i).Text = "Text Box 1(" & i & ")"
Text2(i).Text = "Text Box 2(" & i & ")"
Next
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
    VScroll1.Value = Index + 2
End If
End Sub
Private Sub Text2_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
    VScroll1.Value = Index + 2
End If
End Sub
Private Sub VScroll1_Change()
Select Case VScroll1.Value
Case 4
For i = 0 To 5
Text1(i).Top = i * Text1(0).Height
Text2(i).Top = i * Text1(0).Height
Next
Case 5
For i = 0 To 5
Text1(i).Top = (0 - Text1(0).Height) + (i * Text1(0).Height)
Text2(i).Top = (0 - Text1(0).Height) + (i * Text1(0).Height)
Next
Case 6
For i = 0 To 5
Text1(i).Top = (0 - (Text1(0).Height * 2)) + (i * Text1(0).Height)
Text2(i).Top = (0 - (Text1(0).Height * 2)) + (i * Text1(0).Height)
Next
Case 6
For i = 0 To 5
Text1(i).Top = (0 - (Text1(0).Height * 3)) + (i * Text1(0).Height)
Text2(i).Top = (0 - (Text1(0).Height * 2)) + (i * Text1(0).Height)
Next
End Select
End Sub
This question has already been answered. Start a new discussion instead.