Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > text -> scrollbar value


Reply
 
Thread Tools Display Modes
  #1  
Old 07-30-2003, 04:06 PM
vb24 vb24 is offline
Newcomer
 
Join Date: Jul 2003
Posts: 5
Question text -> scrollbar value


in my program i have a textbox that changes the value of a scrollbar, but if u delete all chars from the textbox i get an error.

it says:

Run-time error '13':

Type mismatch


is there anyway i can fix this?
Reply With Quote
  #2  
Old 07-30-2003, 04:13 PM
VBCODEX's Avatar
VBCODEX VBCODEX is offline
Centurion
 
Join Date: Jun 2003
Location: Far away from you
Posts: 119
Default

this is probably your trying to set 1 of the scrollbar properties to nothing and it doesnt allow it

try

if text1.text = "" then exit sub
__________________
You never realise a mistake until you've made the mistake
[VBc0deX]
Reply With Quote
  #3  
Old 07-30-2003, 04:14 PM
calvn84 calvn84 is offline
Regular
 
Join Date: Mar 2003
Location: Idaho, USA
Posts: 92
Default

Quote:
Originally Posted by vb24
in my program i have a textbox that changes the value of a scrollbar, but if u delete all chars from the textbox i get an error.

it says:

Run-time error '13':

Type mismatch


is there anyway i can fix this?



Put this in whatever function/sub... I'm assuming your only trying to use numbers..
Code:
if text1.text <> "" then scrollbar.value = cint(text1.text)
Reply With Quote
  #4  
Old 07-30-2003, 04:55 PM
vb24 vb24 is offline
Newcomer
 
Join Date: Jul 2003
Posts: 5
Unhappy still same error

i tried both VBCODEX and calvn's code but i still get the same error.

heres my code:
Code:
Private Sub Text1_Change()
Dim num As Integer
num = Text1.Text
HScroll1.Value = num
End Sub
is there anything i need to add? change?
Reply With Quote
  #5  
Old 07-30-2003, 05:34 PM
Lar_19's Avatar
Lar_19 Lar_19 is offline
Senior Contributor

* Expert *
 
Join Date: May 2002
Location: Vancouver, USA
Posts: 999
Default

Try it like this...
Code:
Private Sub Text1_Change() Dim num As Integer ' Use Val() to get the value of the text, ' non-numeric entries will evaluate to zero. num = Val(Text1.Text) ' Make sure you have a valid value before trying to set the scrollbar. If (num >= HScroll1.Min) And (num <= HScroll1.Max) Then HScroll1.Value = num End If End Sub
__________________
1011 0000 1011
Reply With Quote
  #6  
Old 07-30-2003, 05:46 PM
calvn84 calvn84 is offline
Regular
 
Join Date: Mar 2003
Location: Idaho, USA
Posts: 92
Default

You may also want to check your min and max properties on your scrollbar... if max is 1 or some low number, it probably wont give you the result you want... the default max is 32767 so you'll need a larger number to see an actual, visible result.
__________________
-Calvn84
Reply With Quote
  #7  
Old 07-30-2003, 06:01 PM
vb24 vb24 is offline
Newcomer
 
Join Date: Jul 2003
Posts: 5
Talking thx

thx alot lar_19 it works great!
Reply With Quote
  #8  
Old 07-30-2003, 06:16 PM
Lar_19's Avatar
Lar_19 Lar_19 is offline
Senior Contributor

* Expert *
 
Join Date: May 2002
Location: Vancouver, USA
Posts: 999
Default

You are very welcome. I might also suggest using the KeyPress event to restrict data entry into your text box to numbers only. If you do a search you will find numerous examples of how to do it.
__________________
1011 0000 1011
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging keys to edit text Wise_Reeper General 5 12-09-2002 08:01 PM
Wraping text around an image? Serevinus Web Programming 7 06-20-2002 01:46 PM
Text Compare Function cballe General 1 05-24-2002 03:23 AM
Someone Help Me With My Message Boxes Please!! Tajiri17 General 12 03-02-2002 11:29 AM
autoscrolling textbox GrimViper General 14 08-17-2001 05:22 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->