Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2005, 09:12 AM
Authorized User
 
Join Date: Jan 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re-Initial variable to zero

My program has a class level variable calls sum. I am using this value to track a running total when click on Button7_Click. The sum value is displayed in a text box calls pricelst1.Text. I would like to reset this sum value to 0 when I click a button calls Button8_Clickon on my form. Below is my code. Any help would be greatly appreciated:

Dim sum As Double = 0
Dim list As String
Dim total2a As Double
Dim totalkit, total2ip, total2, totalsp, totalfat, totalipt, totalmfp, totalrb, total2cb, totalicb, totalgcb, totalmfpg As Double

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

sum = totalkit + total2ip + total2 + totalsp + totalfat + totalipt + totalmfp + totalrb + total2cb + totalicb + totalgcb + totalmfpg

pricelst1.Text = CStr(sum)

End Sub


Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
'reset sum to 0 and clear all txt boxes.

        sum = 0
       pricelst1.Clear()
        qtytxt.Clear()
        ListBox1.Items.Clear()
        ListBox2.Items.Clear()
    End Sub
 
Old July 12th, 2005, 12:26 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What is it that is happening, and what would you like to have happen instead??
 
Old July 12th, 2005, 01:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

pricelst1 is a textbox or a list box??

if it is a textbox you should be doing pricelst1.text = "0"

HTH

Gonzalo
 
Old July 12th, 2005, 01:41 PM
Authorized User
 
Join Date: Jan 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Finally, i got it to work. thanks all for your inputs.





Similar Threads
Thread Thread Starter Forum Replies Last Post
initial cap a string stolte XSLT 2 November 29th, 2007 12:34 PM
Initial setup PHP5 rjdani Beginning PHP 1 October 16th, 2007 05:11 PM
The ConnectionString property has not been initial libbydoo ASP.NET 1.0 and 1.1 Basics 6 November 22nd, 2006 10:11 PM
The ConnectionString property has not been initial mar0364 ASP.NET 1.0 and 1.1 Basics 6 March 17th, 2006 11:24 PM
Unable to Initial COM Object jonty_11 Visual C++ 1 April 22nd, 2004 05:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.