473,387 Members | 1,517 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,387 software developers and data experts.

Function Return Statement Always Returns 0?

Ok so here is my code(i apologize if some of the code wrapped around)

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Dim currentValue As String
  4.     Dim dblCurrentValue As Double
  5.     Dim newValue As Double
  6.     Dim dblOldValue As Double
  7.  
  8.     Private Function GetBonus(ByRef dblOldValue) As Double
  9.         Dim dblNewValue As Double
  10.         dblNewValue = dblOldValue * 1.1
  11.         Return dblNewValue
  12.  
  13.     End Function
  14.  
  15.     Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
  16.         txtBox.Text = currentValue
  17.         Double.TryParse(currentValue, dblCurrentValue)
  18.  
  19.         newValue = GetBonus(dblCurrentValue)
  20.         txtBox.Text = newValue.ToString()
  21.     End Sub
  22. End Class
My question is, why is it that no matter what number i try to calculate, the end result is a zero? Im really new to this and im completely stumped. Thanks!
Mar 19 '14 #1

✓ answered by Rabbit

Please use code tags when posting code or formatted data.

Line 16 should be flipped. You are currently assigning a blank string to the textbox. If you try to parse that, a blank string will be parsed as 0.

2 2994
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Line 16 should be flipped. You are currently assigning a blank string to the textbox. If you try to parse that, a blank string will be parsed as 0.
Mar 20 '14 #2
thank you so much! Sorry i didnt know their were code tags
Mar 20 '14 #3

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

Similar topics

7
by: A | last post by:
Hi, consider this: char* aClass::printHello() { char* ptr = new char; ptr = "Hello"; return ptr;
94
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
2
by: Michael Klatt | last post by:
I have a resource handle class (call it ResourceHandle) that works like std::auto_ptr to automatically manage resource pointers from a C API (call them T*): class ResourceHandle { public :...
8
by: Ravindranath Gummadidala | last post by:
Hi All: I am trying to understand the C function call mechanism. Please bear with me as I state what I know: "every invocation of a function causes a frame for that function to be pushed on...
6
by: lovecreatesbeauty | last post by:
I ever missed a `return' statement when write a function `int HighDigit(Num)' to get the highest digit of an integer. But even if the `return' statement is ignored the function still can obtain...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
3
by: Thomas Scheiderich | last post by:
I am curious as to why ASP.NET returns values a different way from VB or VB.net (or can you use both). In my one book I have it returning using a return statement ...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
8
by: bdobby | last post by:
Hi. I am relatively new to js, but I did think I was starting to get the hang of it. Then this happened... I have a form with an onsubmit event handler: <form id="uploadForm" method="post"...
12
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.