|
-
Oct 28th, 2002, 04:43 PM
#1
Thread Starter
Addicted Member
Using a dimmed integer on a different sub..
How would I refer to a dimmed integer on a different sub?
I have a button that generates a random number.
I have another button that compares the number with another user-defined number. But I can't figure out how to compare the dimmed integer on a different sub with the user-defined integer...
Last edited by nahya^^; Oct 28th, 2002 at 05:07 PM.
-
Oct 28th, 2002, 04:50 PM
#2
you have to fix that bad VB6 habit of expecting the Default property to always be .Text
If txtGuess.Text < GuessNum Then
you may also need to cast to integer . The above Might work alone though..but if not...
If CInt(txtGuess.Text) < Guessnum
-
Oct 28th, 2002, 04:51 PM
#3
Thread Starter
Addicted Member
Oops. I was late. 
But I have another problem...
I made another button that regenerates the number for the user to guess.
So I dimmed it as an integer, randomly generated the number.
But I want to use that dimmed integer on another sub. How can I do that?
Last edited by nahya^^; Oct 28th, 2002 at 04:54 PM.
-
Oct 28th, 2002, 04:53 PM
#4
hard habit to break since VB6 expected .Text when you did that..
VB.NET is not as nice
-
Oct 28th, 2002, 05:18 PM
#5
Thread Starter
Addicted Member
Any help on my new question?
(I edited out my old question that's already been answered.)
Thanks in advance.
-
Oct 28th, 2002, 05:29 PM
#6
Declare it at the form level and then just assign it a value in the sub or use a function.
VB Code:
Public Class Form1
'auto generated stuff here
'main block of code
dim returnvalue as integer=GenerateRandom()
CompareRandom(returnvalue,othernumber)
'convert subs to functions
Public Function GenerateRandom() as Integer
Return Int(rnd)
end Function
Public Sub CompareRandom(orig as integer,user as integer)
If orig>user then Whatever
end Sub
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
|