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!

Visual Basic 5, Need Programming Help Setting up a ScrollBar! 1

Status
Not open for further replies.

ifilikeituwill

Technical User
May 6, 2009
15
0
0
US
I haven't been able to write this process correct for
VScroll Proceedure and Command Button Routine. I'm
getting Errors in the quotation section of an event
proceedure for one.
Then in my cases, Case 1, it wants an = (1) at the end,
like a value at the end! Something is wrong with each case
selection!
I'm trying to use the VScroll.Value to activate command
Buttons! Can someone help me correct this code Please?
Thanks for reading my Post!

ifilikeituwill

Source Code for the VScroll follows!

Private Sub VScroll1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScroll1.Scroll
Select Case VScroll1.Value()
Case 0
Command0_Click(Nothing, Nothing)
Case 1
Command1_Click(Nothing, Nothing)
Case 2
Command2_Click(Nothing, Nothing)
Case 3
Command3_Click(Nothing, Nothing)
Case 4
Command4_Click(Nothing, Nothing)
Case 5
Command5_Click(Nothing, Nothing)
Case 6
Command6_Click(Nothing, Nothing)
Case 7
Command7_Click(Nothing, Nothing)
Case 8
Command8_Click(Nothing, Nothing)
Case 9
Command9_Click(Nothing, Nothing)
Case 10
Command10_Click(Nothing, Nothing)
Case 11
Command11_Click(Nothing, Nothing)
Case 12
Command12_Click(Nothing, Nothing)
Case 13
Command13_Click(Nothing, Nothing)
Case 14
Command14_Click(Nothing, Nothing)
Case 15
Command15_Click(Nothing, Nothing)
Case 16
Command16_Click(Nothing, Nothing)
Case 17
Command17_Click(Nothing, Nothing)
Case 18
Command18_Click(Nothing, Nothing)
End Select
End Sub

 
Are you trying to write this in VB5 or in .NET (VB2003, VB2005 or VB2008)?

The reason I ask is that the code you posted is .NET code. If it is for .NET then you could try forum796 instead.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Hi Harley!
I'm using just a VB5 Form. VB5 Professional! Not a .net setup! I've never messed around in .net applications!
I do have a different proceedure of this that runs in VB9 Express!
This is what's on the form.
Text1, Text2, Text3. 3 Text windows for text.

Command Buttons that write 3 lines of text to text 1,2, and 3 windows. All the Command Buttons work!

One VScroll I want to click on, the case selected command button by the Scroll.Value will activate a command button which writes to text windows!

Do you follow this? Can anyone help me write this?

ifilikeituwill
 
The code you have there is .NET code.

For VB5/6, something more like this would suit (if you really want to force a button click rather than use a seperate Sub/Function call)
Code:
Private Sub VScroll1_Scroll()
Select Case VScroll1.Value
    Case 0
        Command1_Click
    Case 1
        Command2_Click
    Case 2
        Command3_Click
End Select
End Sub
Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
>I've never messed around in .net

I'm afraid you have. As HarleyQuin has said, the code you show in your original post is quite definitely VB.NET
 
Further to strongm's post
I do have a different proceedure of this that runs in VB9 Express!
VB9.0 is VB2008 (a la .NET).

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
OK HarleyQuinn,
That does help! that's what i'm looking
for!!! Sorry about the .net as I don't know
much about the differences over the years!
Can you tell me how to add a Delay/Pause for
so many milliseconds to the Scroller too? As I hold
the Command Button Down on the Scroller, I want it to
keep going, but it's too fast for Microprocessor program
to respond too! Thanks for all so far!!! I will try it out
this evening and report back on if it works!

ifilikeituwill

 
You could have a look at the Sleep API.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Hi HarleyQuinn,
I tried this in VB5 and it does nothing! Sorry, it does nothing!
This is the proceedure you suggested me to try:

Private Sub VScroll1_Scroll()
Select Case VScroll1.Value
Case 0
Command1_Click
Case 1
Command2_Click
Case 2
Command3_Click
End Select
End Sub

I have a new VScroll Project that is more complete up on
this Website! Half of it already works. Feel free to try
out, or look at the complete VB5 project!
Do you have Visual Basic 5 on your present computer?
I do! And that's how I'm doing the tries from suggestions!
Thanks for your help!!

ifilikeituwill


 
Are the values of VScroll1.Value ever 0,1 or 2? If they aren't it'll never meet any of the select case criteria...

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Actually, just set the max property of the scrollbar to 3 and then the code will work. You can then test with differing values of the scrollbar to make the controls visible/invisible.

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Hi HarleyQuinn!
Well setting the value to 3 isn't accomplishing what I'm trying to do HarleyQuinn. Please see what i mean in the new post. I guess i didn't explain the process i'm trying to do complete enough in this post! So I took another approach/stab at it in the new post! Thanks!

ifilikeituwill
 
The reason I suggested you try setting it to 3 is that then the values in your select case will definitely fire. You can then verify the code works for you in that scenario and then you can change the Max property to whatever you want. Once you've done that you'd need to debug the code to find out what the values you'd need to use for your select case branches to fire.

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Hi Guys!
This is what I have in programming
and it still won't work!
VScroll max=5 min=0

Private Sub Command0_Click()
Text1.Text = "Cmd 0 Clicked"
Text2.Text = "-2"
VScroll1.Value = (0)
Text3.Text = "Scroll 0"
End Sub
Private Sub Command1_Click()
Text1.Text = "Cmd 1 Clicked"
Text2.Text = "-1"
VScroll1.Value = (1)
Text3.Text = "Scroll 1"
End Sub
Private Sub Command2_Click()
Text1.Text = "Cmd 2 Clicked"
Text2.Text = " 0"
VScroll1.Value = (2)
Text3.Text = "Scroll 2"
End Sub
Private Sub Command3_Click()
Text1.Text = "Cmd 3 Clicked"
Text2.Text = "+1"
VScroll1.Value = (3)
Text3.Text = "Scroll 3"
End Sub
Private Sub Command4_Click()
Text1.Text = "Cmd 4 Clicked"
Text2.Text = "+2"
VScroll1.Value = (4)
Text3.Text = "Scroll 4"
End Sub
Private Sub VScroll1_Scroll()
Select Case VScroll1.Value
Case 0
Command0_Click
Case 1
Command1_Click
Case 2
Command2_Click
Case 3
Command3_Click
Case 4
Command4_Click
End Select
End Sub
Private Sub Exit_Click()
End
End Sub

Thanks for the Help anyway as i guess
this is not a doable process in VB5!
 
The Scroll event only occurs if you drag the thumb bar. If you are clicking the up and down arrows then those trigger the Change event. Since the Scroll event itself triggers a Change event move all your code that is in VScroll1_Scroll into VScroll1_Change.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top