I have some code already in place but my problem lies with trying to add 4 textboxs (currency) to another textbox5. when i try to add them all together 1 thru 4 it works. but when I try to add 1 thru 3 leaving off #4 it does not work. same thing happens if i leave off textboxs 2 and 3 . can anybody assist me please. -
Private Sub cmdenter_click()
-
Dim STRTOTAL As Currency
-
Dim INTNUM1 As Currency
-
Dim INTNUM2 As Currency
-
Dim intNUM3 As Currency
-
Dim INTANSWER As Currency
-
-
-
STRTOTAL = Me.TextBox5.Value
-
INTNUM1 = TextBox1.Value
-
INTNUM2 = TextBox2.Value
-
intNUM3 = TextBox3.Value
-
intNUM4 = TextBox4.Value
-
-
If INTNUM2 = "" And intNUM3 = "" And intNUM4 = "" Then
-
INTANSWER = INTNUM1
-
Me.TextBox5.Value = " SUM; " & INTANSWER
-
Else
-
-
If intNUM3 = "" And intNUM4 = "" Then
-
INTANSWER = (INTNUM1 + INTNUM2)
-
Me.TextBox5.Value = " SUM; " & INTANSWER
-
Else
-
-
If intNUM4 = "" Then
-
INTANSWER = INTNUM1 + INTNUM2 + intNUM3
-
Me.TextBox5.Value = " SUM; " & INTANSWER
-
Else
-
-
'If STRTOTAL = "" Then
-
INTANSWER = INTNUM1 + INTNUM2 + intNUM3 + intNUM4
-
Me.TextBox5.Value = " SUM; " & INTANSWER
-
End If
-
End If
-
End If
-
End Sub
-
-
There is no DIM for num4 !
There is no .value for a Textbox !
This is working in VB6= - Private Sub cmdenter_click()
-
Dim STRTOTAL As Currency
-
Dim INTNUM1 As Currency
-
Dim INTNUM2 As Currency
-
Dim intNUM3 As Currency
-
Dim intNUM4 As Currency
-
Dim INTANSWER As Currency
-
INTNUM1 = Val(Textbox1.Text)
-
INTNUM2 = Val(Textbox2.Text)
-
intNUM3 = Val(Textbox3.Text)
-
intNUM4 = Val(Textbox4.Text)
-
If INTNUM2 = 0 And intNUM3 = 0 And intNUM4 = 0 Then
-
INTANSWER = INTNUM1
-
ElseIf intNUM3 = 0 And intNUM4 = 0 Then
-
INTANSWER = (INTNUM1 + INTNUM2)
-
ElseIf intNUM4 = 0 Then
-
INTANSWER = INTNUM1 + INTNUM2 + intNUM3
-
Else
-
INTANSWER = INTNUM1 + INTNUM2 + intNUM3 + intNUM4
-
End If
-
Textbox5.Text = " SUM; " & INTANSWER
-
STRTOTAL = INTANSWER
-
End Sub
But also this: - Private Sub cmdenter_click()
-
Textbox5.Text = " SUM; " & (Val(Textbox1.Text) + Val(Textbox2.Text) + _
-
Val(Textbox3.Text) + Val(Textbox4.Text))
-
End Sub
3 1316
There is no DIM for num4 !
There is no .value for a Textbox !
This is working in VB6= - Private Sub cmdenter_click()
-
Dim STRTOTAL As Currency
-
Dim INTNUM1 As Currency
-
Dim INTNUM2 As Currency
-
Dim intNUM3 As Currency
-
Dim intNUM4 As Currency
-
Dim INTANSWER As Currency
-
INTNUM1 = Val(Textbox1.Text)
-
INTNUM2 = Val(Textbox2.Text)
-
intNUM3 = Val(Textbox3.Text)
-
intNUM4 = Val(Textbox4.Text)
-
If INTNUM2 = 0 And intNUM3 = 0 And intNUM4 = 0 Then
-
INTANSWER = INTNUM1
-
ElseIf intNUM3 = 0 And intNUM4 = 0 Then
-
INTANSWER = (INTNUM1 + INTNUM2)
-
ElseIf intNUM4 = 0 Then
-
INTANSWER = INTNUM1 + INTNUM2 + intNUM3
-
Else
-
INTANSWER = INTNUM1 + INTNUM2 + intNUM3 + intNUM4
-
End If
-
Textbox5.Text = " SUM; " & INTANSWER
-
STRTOTAL = INTANSWER
-
End Sub
But also this: - Private Sub cmdenter_click()
-
Textbox5.Text = " SUM; " & (Val(Textbox1.Text) + Val(Textbox2.Text) + _
-
Val(Textbox3.Text) + Val(Textbox4.Text))
-
End Sub
ggeu, in VBA, which the OP states that they are using in the title of this post, there is a .Value property for text boxes as those lovely Form 2.0 controls are what the office products use. Beyond that, good catch on the missing declaration, however, using Val puts a double into the currency variable...
Val Function
Returns the numbers contained in a string as a numeric value of appropriate type.
Syntax
Val(string)
The required stringargument is any validstring expression.
Remarks
The Val function stops reading the string at the first character it can't recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes the radix prefixes &O (for octal) and &H (for hexadecimal). Blanks, tabs, and linefeed characters are stripped from the argument.
The following returns the value 1615198:
Val(" 1615 198th Street N.E.")
In the code below, Val returns the decimal value -1 for the hexadecimal value shown:
Val("&HFFFF")
Note The Val function recognizes only the period (.) as a valid decimal separator. When different decimal separators are used, as in international applications, use CDbl instead to convert a string to a number.
So, if the textbox contains $1,034.34, Val will return zero (0) while ccur, which is the data type one is putting the values into, and cdbl will return 1,034.34...
Good Luck
Yes; sorry, My mistake.
I hope this will help (see also attachment)= - Private Sub cmdenter2_Click()
-
Dim TEMPTXT As String
-
Dim INTNUM1 As Currency
-
Dim INTNUM2 As Currency
-
Dim intNUM3 As Currency
-
Dim intNUM4 As Currency
-
TEMPTXT = Replace(TextBox1.Value, "$", "")
-
INTNUM1 = CCur(Replace(TEMPTXT, " ", ""))
-
-
TEMPTXT = Replace(TextBox2.Value, "$", "")
-
INTNUM2 = CCur(Replace(TEMPTXT, " ", ""))
-
-
TEMPTXT = Replace(TextBox3.Value, "$", "")
-
intNUM3 = CCur(Replace(TEMPTXT, " ", ""))
-
-
TEMPTXT = Replace(TextBox4.Value, "$", "")
-
intNUM4 = CCur(Replace(TEMPTXT, " ", ""))
-
-
TextBox5.Value = " SUM; " & INTNUM1 + INTNUM2 + intNUM3 + intNUM4
-
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: AMT2K5 |
last post by:
Hello folks, I seem to have recieved a segfault within my function but
am unsure on how to resolve it. I understand that it means that
somewhere something is trying to access memory that is not...
|
by: Dalan |
last post by:
I have tried both methods of using DSum and creating a Function to
address summing some number columns, but to no avail. Since this has
been a popular topic over the years, I'm sure I'll receive...
|
by: Dalan |
last post by:
I'm experiencing a Query Syntax Error with an Access 97 Db. Actually,
the query performs as expected when adding any new records or editing
existing ones and even deleting records, EXCEPT when the...
|
by: CSDunn |
last post by:
Hello,
I need some assistance with error handling in an Access 2003 Project
form. The project is has a data source connection to a SQL Server 2000
database. The main form is named...
|
by: Luis Esteban Valencia |
last post by:
I've never worked with LDAP before, and I'm having issues connecting to our
AD for user authentication. I am trying to use the code found at:
...
|
by: Joe Ross |
last post by:
(Apologies in advance if there is a better forum for asking advice on this
topic).
Our ASP.NET application occasionally starts spitting out OutOfMemory
exceptions. When this happens, the memory...
|
by: mwalk66 |
last post by:
I have been able to create a web based company phone book by retrieving
the last name, first name, email address and telephone # from active
directory. However I need serious assistance in...
|
by: serpius |
last post by:
Hello Everyone,
I am a beginner in VB.Net 2003 and am taking classes in beginning VB.net. To make a long story short, I am looking for real samples of coding in Console Apps.
I am the type of...
|
by: Scubadude |
last post by:
I am looking for some assistance in 'fine-tuning' my preferences as I set-up
my system to learn PHP.
I am running Komodo professional, version 3.5.3, build 262321, platform
win32-x86.
Under...
|
by: quack |
last post by:
In SQL Server 2005 I have database mail, I need experienced assistance with a project- when a new record is created send an html message to the new records column "Authorize" , for example...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |