Hi,
I'm trying to write a simple program to print invoices for people I do work
for. I've got a form with textboxes for descriptions and amounts for items,
and some code for printing the invoices. It all works except for the one
line that adds all of the item amounts. At run time, a "type mismatch"
error is thrown. I've tried a couple of different things, but the code
won't work. Is there something special about adding currency I'm missing?
I've also tried making everything a string, and when I add amounts, it will
just concatenate the strings. Also, this method won't let me subtract
discounts.
Any help or code snippets would be greatly appreciated.
Thanks,
Steven Smith 5 1197
I should probably show you the code in question.....
Dim AmountDue As Currency
AmountDue = Item1Amt.Text + Item2Amt.Text + Item3Amt.Text +
Item4Amt.Text + Item5Amt.Text + Item6Amt.Text + Item7Amt.Text +
Item8Amt.Text - Item9Amt.Text - ItemAAmt.Text
Thanks again...
Steven Smith <sl****@webbox. com> wrote in
news:l7******** *********@twist er.nyroc.rr.com : Hi,
I'm trying to write a simple program to print invoices for people I do work for. I've got a form with textboxes for descriptions and amounts for items, and some code for printing the invoices. It all works except for the one line that adds all of the item amounts. At run time, a "type mismatch" error is thrown. I've tried a couple of different things, but the code won't work. Is there something special about adding currency I'm missing? I've also tried making everything a string, and when I add amounts, it will just concatenate the strings. Also, this method won't let me subtract discounts.
Any help or code snippets would be greatly appreciated.
Thanks,
Steven Smith
"Steven Smith" <sl****@webbox. com> schrieb: [VB6-related question]
Note that the group "microsoft.publ ic.dotnet.langu ages.vb" is related to
VB.NET. VB6 groups can be found in the "microsoft.publ ic.vb.*" hierarchy.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Try converting the text values to numbers before adding them.
AmountDue = val(Item1Amt.Te xt) + val(Item2Amt.Te xt) +
val(Item3Amt.Te xt) + val(Item4Amt.Te xt) + val(Item5Amt.Te xt) +
val(Item6Amt.Te xt) + VItem7Amt.Text) + val(Item8Amt.Te xt) -
val(Item9Amt.Te xt) - val(ItemAAmt.Te xt)
On Mon, 15 May 2006 19:05:42 GMT, Steven Smith <sl****@webbox. com>
wrote: I should probably show you the code in question.....
Dim AmountDue As Currency AmountDue = Item1Amt.Text + Item2Amt.Text + Item3Amt.Text + Item4Amt.Tex t + Item5Amt.Text + Item6Amt.Text + Item7Amt.Text + Item8Amt.Tex t - Item9Amt.Text - ItemAAmt.Text
Thanks again...
Steven Smith <sl****@webbox. com> wrote in news:l7******* **********@twis ter.nyroc.rr.co m:
Hi,
I'm trying to write a simple program to print invoices for people I do work for. I've got a form with textboxes for descriptions and amounts for items, and some code for printing the invoices. It all works except for the one line that adds all of the item amounts. At run time, a "type mismatch" error is thrown. I've tried a couple of different things, but the code won't work. Is there something special about adding currency I'm missing? I've also tried making everything a string, and when I add amounts, it will just concatenate the strings. Also, this method won't let me subtract discounts.
Any help or code snippets would be greatly appreciated.
Thanks,
Steven Smith
Thanks John.... that worked perfectly.
Ah, the joys of being a newbie!
Steve
John <lo**@sig.net > wrote in news:2qnh62tgjm p4j2v2rgoe3li1g 89ogdh014@
4ax.com: Try converting the text values to numbers before adding them.
AmountDue = val(Item1Amt.Te xt) + val(Item2Amt.Te xt) + val(Item3Amt.Te xt) + val(Item4Amt.Te xt) + val(Item5Amt.Te xt) + val(Item6Amt.Te xt) + VItem7Amt.Text) + val(Item8Amt.Te xt) - val(Item9Amt.Te xt) - val(ItemAAmt.Te xt) On Mon, 15 May 2006 19:05:42 GMT, Steven Smith <sl****@webbox. com> wrote:
I should probably show you the code in question.....
Dim AmountDue As Currency AmountDue = Item1Amt.Text + Item2Amt.Text + Item3Amt.Text + Item4Amt.Te xt + Item5Amt.Text + Item6Amt.Text + Item7Amt.Text + Item8Amt.Te xt - Item9Amt.Text - ItemAAmt.Text
Thanks again...
Steven Smith <sl****@webbox. com> wrote in news:l7****** ***********@twi ster.nyroc.rr.c om:
Hi,
I'm trying to write a simple program to print invoices for people I
do work for. I've got a form with textboxes for descriptions and amounts for items, and some code for printing the invoices. It all works except for the one line that adds all of the item amounts. At run time, a "type mismatch" error is thrown. I've tried a couple of different things, but the code won't work. Is there something special about adding currency I'm missing? I've also tried making everything
a string, and when I add amounts, it will just concatenate the strings. Also, this method won't let me subtract discounts.
Any help or code snippets would be greatly appreciated.
Thanks,
Steven Smith
A better solution would be:
Dim AmountDue as Currency
AmountDue = 0
if isnumeric(item1 Amt.text) then amountDue = AmountDue + ccur(item1amt.t ext)
if isnumeric(item2 Amt.text) then amountDue = AmountDue + ccur(item2amt.t ext)
if isnumeric(item3 Amt.text) then amountDue = AmountDue + ccur(item3amt.t ext)
if isnumeric(item4 Amt.text) then amountDue = AmountDue + ccur(item4amt.t ext)
if isnumeric(item5 Amt.text) then amountDue = AmountDue + ccur(item5amt.t ext)
if isnumeric(item6 Amt.text) then amountDue = AmountDue + ccur(item6amt.t ext)
if isnumeric(item7 Amt.text) then amountDue = AmountDue + ccur(item7amt.t ext)
if isnumeric(item8 Amt.text) then amountDue = AmountDue + ccur(item8amt.t ext)
if isnumeric(item9 Amt.text) then amountDue = AmountDue - ccur(item9amt.t ext)
if isnumeric(itemA Amt.text) then amountDue = AmountDue - ccur(itemAamt.t ext)
Also, use the CCur function to convert from the text box string values to
currency - you'll avoid rounding errors that the Val function can introduce.
Also note that VB 6 implictely uses the .TEXT property if you don't, but VB
2002 and later require it. It makes your code more specific so it's a
decent habit to be in anyway.
Mike Ober.
"John" <lo**@sig.net > wrote in message
news:2q******** *************** *********@4ax.c om... Try converting the text values to numbers before adding them.
AmountDue = val(Item1Amt.Te xt) + val(Item2Amt.Te xt) + val(Item3Amt.Te xt) + val(Item4Amt.Te xt) + val(Item5Amt.Te xt) + val(Item6Amt.Te xt) + VItem7Amt.Text) + val(Item8Amt.Te xt) - val(Item9Amt.Te xt) - val(ItemAAmt.Te xt) On Mon, 15 May 2006 19:05:42 GMT, Steven Smith <sl****@webbox. com> wrote:
I should probably show you the code in question.....
Dim AmountDue As Currency AmountDue = Item1Amt.Text + Item2Amt.Text + Item3Amt.Text + Item4Amt.Tex t + Item5Amt.Text + Item6Amt.Text + Item7Amt.Text + Item8Amt.Tex t - Item9Amt.Text - ItemAAmt.Text
Thanks again...
Steven Smith <sl****@webbox. com> wrote in news:l7******* **********@twis ter.nyroc.rr.co m:
Hi,
I'm trying to write a simple program to print invoices for people I do work for. I've got a form with textboxes for descriptions and amounts for items, and some code for printing the invoices. It all works except for the one line that adds all of the item amounts. At run time, a "type mismatch" error is thrown. I've tried a couple of different things, but the code won't work. Is there something special about adding currency I'm missing? I've also tried making everything a string, and when I add amounts, it will just concatenate the strings. Also, this method won't let me subtract discounts.
Any help or code snippets would be greatly appreciated.
Thanks,
Steven Smith
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ed |
last post by:
Hoping someone an assist me urgently. I would truly appreciate and help.
I have a form and prices are based on 'price break'.
1.The price break fields work fine, but I cannot for the life of me add more
than one to a page.
2. Also need to add the two results to a 'total' field. (See code attached).
Many thanks in advance.
|
by: MrTang001 |
last post by:
How I can fix this problem?
I don't know why it alway prompted (first use this function). I have
use newDollars, newCents... to access the base class member variable.
And the member functions for Initialize() and Print(), is it function
overloading? it already have this functions in the base class.
Pls let me know what problem of its! Thx
------------------------------------------------------------------
Result
|
by: Dave56 |
last post by:
I am trying to create an class (in vb.net) that will serialize to produce
xml as follows:
------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<TotalCostData>
<Ship DataType="Money" Currency="USD">1.00</Ship>
<Total DataType="Money" Currency="USD">35.00</Total>
</TotalCostData>
------------------------------------------
|
by: Redduck |
last post by:
Hello everyone. I am frustrated, I have written the simple program
below for a class and I am having problems with the DO-WHILE loop. On
the first run through the loop, everything works well, the menu is
displayed, the input is registered and the loop runs. On the second
(and following) runs the menu is printed twice. I am sure there is
something very basic that I am missing, but I cannot see it. Can
anyone help?
Thanks in advance.
|
by: Steven Smith |
last post by:
Hi,
I'm trying to write a simple program to print invoices for people I do work
for. I've got a form with textboxes for descriptions and amounts for items,
and some code for printing the invoices. It all works except for the one
line that adds all of the item amounts. At run time, a "type mismatch"
error is thrown. I've tried a couple of different things, but the code
won't work. Is there something special about adding currency I'm...
| |
by: luis.c.torres |
last post by:
Hello.
I have and unbound form with a subform.
The form has 4 controls (a combo, two txt boxes and a button).
The combo has the filter criteria (Equal to, newer than, older than and
between) and the txt boxes are for the data I want to search for.
The textboxes are locked and I have two little buttons that open a
calendar form from where I get the chosen dates.
When I click the (filter) button on the form I can't seem to filter the
|
by: =?Utf-8?B?UmljaGFyZCBUb2NjaQ==?= |
last post by:
I'm learning Visual Basic using the .Net Framework 2.0. I have been playing
with consuming web services in applications.
I am using a free web service that gives me information for currency
conversion. The web service I am using is:
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
It's got pretty much everything I need, but I'm running into trouble.
|
by: favor08 |
last post by:
I'm have automated the creation of an email from Access; whic works
fine,
but the new email doesn't have the user's default signature on it. Is
there any way to either have it find the user's default signature and
add it to the bottom of the email.
Here is my code for sending the emails:
Function SendEmail()
Dim rst As DAO.Recordset
|
by: Guillermo_Lopez |
last post by:
Hello All,
I am using VBA in access to perform some calculations. There is a
particular sumation that is wrong (barely).
this code is withing a loop.
TDist = TDist + TempDist
Both TDist and TempDist are declared as doubles:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |