473,394 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem in calculating and displaying price in textbox

Prathap
37
Hi all,
Check this code and please tell me a solution.I have 2 buttons (Pizza & pepsi),the price should display in textbox8 when i click on button, here the price had shown in Textbox8,but it is not getting added with next price when i click second button.
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  2.     con.ConnectionString = str
  3.     TextBox8.Text = 0.0
  4.     adp = New SqlDataAdapter("select Item,Price from Bill where Id = '1'", con)
  5.     adp.Fill(ds)
  6.     DataGridView1.DataSource = ds.Tables(0)
  7.     TextBox8.Text = ds.Tables(0).Rows(0)("Price") + TextBox8.Text
  8.     End Sub
Jan 16 '12 #1
2 1760
C CSR
144 100+
You put the first value in (the sum: x). You add a new value (y) to the old, but the old value isn't included in the new sum. It looks like:
init x = 0
x: old value
y: new value
x = x + y

Are you reinitializing x to 0 before you recalculate the new value? If y is showing up and x dissappears, then x has lost its value or it is being referenced correctly.

I'm just guessing.
Jan 16 '12 #2
C CSR
144 100+
In the last part of THE LAST sentence, I mean maybe x ISN'T being referenced correctly (that is, if you're not reinitializing it to 0).
Jan 16 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Stephen Miller | last post by:
Firstly, sorry for the long post, but I've included a fair bit of sample data. Im doing a comparision of 10yr Bond prices and CPI adjustments, with an 18 week moving average of the CPI. I'm...
1
by: Maziar Aflatoun | last post by:
Hi everyone, I have this DataGrid that I bind to a DataTable. However, instead of displaying the column 'Qty', I like to place it in a textbox and display the value of Qty as the default value...
1
by: Ziemowit Skowronski | last post by:
Hi, I have a problem with displaying unicode strings in ASP.NET (C#). I recieve data from MS SQL Server database and use them to construct navigation on the page. Because I'm from Poland, I have...
2
by: Raghavendra V | last post by:
Hi all, I have a datagrid and textboxes as columns. But when i say the textbox property as PASSWORD the * (stars) does not display in the password text box at runtime. But when it is a normal...
1
by: Patrick.O.Ige | last post by:
Hello guys i made a Datagrid with Editing,Update and Cancel using VS.NET. to my surprise nothing is on the screen after compilation .. By code below:- Imports System.Data Imports...
5
by: sejal17 | last post by:
hello everyone, I have a problem with displaying records between two dates.Below is my designing page: start date: combobox of month(smonth) & combobox of year(syear) end date :...
10
vikas1111
by: vikas1111 | last post by:
Hi All Can anyone give me an idea to solve the problem.. My Problem is ,, I want to Retrieving data from database and displaying in textbox... If anybody have link of some good tutorial on...
3
by: rhandoo | last post by:
Hi, I am facing the problem in displaying the special characters like ( ` ) GRAVE ACCENT in C# windows Application. I am using oracle as back end. In oracle database table the string contain...
3
by: Hataf | last post by:
Hi! I am having a problem in displaying images from database. This the code gallery.php <?php session_start(); if(isset($_SESSION)){} //die('ERROR:'.mysql_error());
0
by: apeg | last post by:
Hi Guys. I have a problem in displaying the data in my report viewer which is crystal report based on the value of checkbox. When i select and check multiple item that i want to print, only one item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.