Professional Web Applications Themes

Stange effects? - ASP.NET General

One of our students wrote on a vb web form Public intIndex As Integer = 0 Private Sub btSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSet.Click intIndex = 2 lblOriginal.Text = "intIndex = : " & CType(intIndex, String) End Sub Private Sub btAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btAdd.Click intIndex += intIndex lblResult.Text = "intIndex = : " & CType(intIndex, String) End Sub Clicking on the button set wil seed the integer int Index with 2 Clicking on the Add button adss the index to it's self Both times de value is displayed on the ...

  1. #1

    Default Stange effects?

    One of our students wrote on a vb web form
    Public intIndex As Integer = 0


    Private Sub btSet_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btSet.Click
    intIndex = 2
    lblOriginal.Text = "intIndex = : " & CType(intIndex, String)
    End Sub


    Private Sub btAdd_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btAdd.Click
    intIndex += intIndex
    lblResult.Text = "intIndex = : " & CType(intIndex, String)
    End Sub

    Clicking on the button set wil seed the integer int Index with 2
    Clicking on the Add button adss the index to it's self
    Both times de value is displayed on the screen.
    Strait forward no?
    Cliking the btAdd displays a "0" Why?????
    --
    Voor mensen en machines die werken
    http://ww.highpotech.nl


    Alexander Guest

  2. #2

    Default Re: Stange effects?

    I'm not sure I understand the question. You have 2 buttons on the page, both
    of which display a calculated result from an integer field value that is
    initialized to 0. The first button's Event Handler sets the value of the
    integer to 2, and displays that value (2). The second button's Event Handler
    doubles the value of the same integer and displays that. Therefore, as the
    integer is initialized to 0, if you click the first button and then the
    second, the second will display 4 (2 + 2). If you click the second button
    first, the second will display 0 (0 + 0). Is there a problem with that?

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    The more I learn, the less I know.

    "Alexander M. Polak" <nl> wrote in message
    news:bii0ro$iv8$hccnet.nl... 


    Kevin Guest

  3. #3

    Default Re: Stange effects?

    Hello

    The value int the integer value is not saved between trips to the server, so
    every time it is initialized to zero.
    To save the value, use the ViewState collection, then retrieve the value in
    the Load event

    Regards

    "Alexander M. Polak" <nl> wrote in message
    news:bii0ro$iv8$hccnet.nl... 


    Sherif Guest

  4. #4

    Default Re: Stange effects?

    Yes thanks
    Found te same answer just a minute ago.
    Even if public every trip around the integer is reset again to the old value

    "Sherif ElMetainy" <net> wrote in message
    news:%phx.gbl... 
    so 
    in 
    >
    >[/ref]


    Alexander Guest

Similar Threads

  1. PS7.0.1 very stange layer effects problem
    By iRudi@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 13
    Last Post: September 17th, 12:00 PM
  2. Stange error
    By ezd_macromedia in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: September 6th, 03:54 PM
  3. Stange Behavior with text on a path
    By Jeff_Gardner@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 10
    Last Post: August 12th, 02:09 AM
  4. Pseudo Terminals and Stange Vi problem
    By Peter in forum UNIX Programming
    Replies: 3
    Last Post: September 11th, 03:58 PM
  5. Gtk2: stange problem with notebook ?
    By oxman in forum Ruby
    Replies: 1
    Last Post: August 15th, 08:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139