|
-
Nov 10th, 2003, 05:47 PM
#1
Thread Starter
Lively Member
ReDim....?????
Ok...
My Goal: To make my form fade out when I exit the program...
My Problem: I cannot reset A as A-.05
Here is what I did
I set A as Integer
A=1 BLAH BLAH BLAH
Then I have my button and I enabled my timer
I set my timer to 100 (1/10 of a second)
In the timer code i have this...
MyBase.Opacity=(A-.05)
And it does that every 1/10 of a second, the problem then is that it always thinks A=1
I want it to reset A to A-.05 (.95) so that the opacity keeps getting smaller
I know that on TIBASIC I would simply do A-.05->A But that does not seem to work in VB.NET
So what do i Do? :-D
It is like wiping your ass with silk, I love it!
-
Nov 10th, 2003, 05:56 PM
#2
The problem is that you are declaring it as in integer and integers are whole numbers (no decimals) switch it to a single and you'll be all good.
-
Nov 10th, 2003, 05:57 PM
#3
Thread Starter
Lively Member
oh haha, i'm such a idiot That takes care of one issue, that I didnt even think about...Thanks
But what i really want is to know how to Redefine A using A...
It is like wiping your ass with silk, I love it!
-
Nov 10th, 2003, 05:58 PM
#4
You just assign it to itself.
VB Code:
A=A-0.5
'you can also shortcut adding and subtracting
A+=1 'adds 1
A-=1 'subtracts 1
-
Nov 10th, 2003, 06:01 PM
#5
Thread Starter
Lively Member
So should i not have set it as a string? or...
so it'll look like this
A=A-.05
MyBase.opacity=A
like that?
It is like wiping your ass with silk, I love it!
-
Nov 10th, 2003, 06:14 PM
#6
String? You mean Single? You can't use A without declaring it. Actually if you are just changing the opacity then try this wherever you need to decrease the opacity:
Mybase.Opacity-=0.5
-
Nov 10th, 2003, 06:23 PM
#7
Thread Starter
Lively Member
That's a good idea, i didnt think of that thanks!
but say i did wanna reset A how would i do that?
It is like wiping your ass with silk, I love it!
-
Nov 10th, 2003, 06:31 PM
#8
Reset it to what? 100%
MyBase.Opacity=1
I believe Opacity is just a single between 1 and 0, 1 =100%, 0 =0%, .5 = 50%
-
Nov 10th, 2003, 06:38 PM
#9
Thread Starter
Lively Member
Right i know that...
I'm sorry my termonology is crap...
Not reset opacity
like Re Define "A" Is what i meant....
I think this is a wonderful example of how there are many ways (I count 3 in this case) to do one simple thing
1) set opacity value as a number then subtract .05 from it
2)Mybase.Opacity-=0.5
3)and if anyone followed the one that i thought was the only way from the begnning
It is like wiping your ass with silk, I love it!
-
Nov 10th, 2003, 06:43 PM
#10
I'm still not sure what you mean by reset? Reset what? Explain it further and maybe I'll see what you mean. What do you expect to happen when you reset?
-
Nov 10th, 2003, 10:30 PM
#11
Thread Starter
Lively Member
Not reset, but like Re Define.... The string "A" Redefine it as a new number...like
Code:
'Define A
Dim A As Integer
A=1
'RE DEFINE A
A=A+1
This is what i mean, i think this is how you would do it...It sets A as a new number, and if it was in the timer, it would do that every 10th of a second thus making the opacity smaller every 1/10 of a second
It is like wiping your ass with silk, I love it!
-
Nov 11th, 2003, 12:12 AM
#12
Addicted Member
i know you;ve already done it but anyway dont forget to declare the A variable outside the tick handler of the timer, so it value doesnt reset each time the procedure is called
-
Nov 11th, 2003, 12:31 AM
#13
Addicted Member
its doesnt seem to be very goodway to write the code, but anyway in can help you in your "redefinig variable" question
Code:
Dim a As Single
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Do While Me.Opacity > 0
a += 0.01
Me.Opacity = 1 - a
Loop
End Sub
Last edited by persianboy; Nov 11th, 2003 at 12:38 AM.
-
Nov 11th, 2003, 08:28 AM
#14
Thread Starter
Lively Member
Thanks, yeah it is a bad way to write the code, but i'm a beginner so that's what i'm here for...I'm only a junior in High School, I"m learning it at my High School it is a great class, the teachers is great! I also wanted to share the other language he's teaching to the Advanced Comp Sci people is C#, how many other schools are teaching that? to highschool students? that's what i thought!
It is like wiping your ass with silk, I love it!
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
|