Results 1 to 14 of 14

Thread: ReDim....?????

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96

    Unhappy 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!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96
    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!

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You just assign it to itself.
    VB Code:
    1. A=A-0.5
    2. 'you can also shortcut adding and subtracting
    3. A+=1 'adds 1
    4. A-=1 'subtracts 1

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96
    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!

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96
    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!

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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%

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96
    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!

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96
    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!

  12. #12
    Addicted Member
    Join Date
    Sep 2003
    Posts
    227
    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

  13. #13
    Addicted Member
    Join Date
    Sep 2003
    Posts
    227
    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.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Iowa
    Posts
    96
    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
  •  



Click Here to Expand Forum to Full Width