473,399 Members | 2,774 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,399 software developers and data experts.

why won't this simple code work???

Hello All,

I am trying to add two Text fields together on my Form. But when I
run the following code, I get an error that says:

___________
code:
___________

Private Sub sum_click()
Label.sum = Text1.id1 + Text2.id2
End Sub
___________
error:
___________

Run-time error '424':
Object required


Now, I'm a bit of a newbie, but I've tried everything and can't get
this to run. Any ideas?

TIA,

Mike
Jul 17 '05 #1
3 2442
Try
Private Sub sum_click()
Label.sum = val(Text1) + val(Text2)
End Sub

The default property for a textbox is .Text so you don't have to use it.
When using numbers, the textbox contains text so it has to be converted to a
number. Caution: if you haven't filtered out text on entry, the Val
function will give you some strange results. Type VAL in your help file to
see details.

Suzette

"Ixnay" <ms******@yahoo.com> wrote in message
news:21**************************@posting.google.c om...
Hello All,

I am trying to add two Text fields together on my Form. But when I
run the following code, I get an error that says:

___________
code:
___________

Private Sub sum_click()
Label.sum = Text1.id1 + Text2.id2
End Sub
___________
error:
___________

Run-time error '424':
Object required


Now, I'm a bit of a newbie, but I've tried everything and can't get
this to run. Any ideas?

TIA,

Mike

Jul 17 '05 #2
Try :

Private Sub Label1_Click()
Label1.Caption = Text1.Text + Text2.Text
End Sub

If you are wanting to add numerical figures in Text1
and Text2, that will require other code. Hopefully,
this will get you started.

--
Thanks !

Jim

[ lo*****@yahoo.com to reply directly ]

"If you are living like there is no God ...
... you better be right !"

Jul 17 '05 #3
If the contents of the text boxes ar numeric, (12345) then try this:

Private Sub Label1_Click()
'Both textboxes contain 12345
Label1.Caption = Int(Text1.Text) + Int(Text2.Text)
End Sub

It should produce ...... 24690

If the contents of the text boxes are alphanumeric, (abcdef) then try this:

Private Sub Label1_Click()
'Both textboxes contain abcdef
Label1.Caption = Text1.Text & " " & Text2.Text
End Sub

It should produce ...... abcdef abcdef
"Logit" <jd*******************@alltel.net> wrote in message
news:cg***********@fe05.atl2.webusenet.com...
Try :

Private Sub Label1_Click()
Label1.Caption = Text1.Text + Text2.Text
End Sub

If you are wanting to add numerical figures in Text1
and Text2, that will require other code. Hopefully,
this will get you started.

--
Thanks !

Jim

[ lo*****@yahoo.com to reply directly ]

"If you are living like there is no God ...
... you better be right !"

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine...
10
by: Mark | last post by:
Hi, I'm a complete newbie to IIs and ASP (come from the Apache/Cold Fusion world ). I've created a very simple ASP test page: <%@ Language=VBScript %> <% Response.Write "This is a test ASP...
13
by: owen_meany | last post by:
I just installed SP2. now my .asp scripts won't run. .aspx scripts run fine. It's just .asp for some reason. I keep getting the following error: "Either a required impersonation level was...
8
by: nescio | last post by:
hello, i have got a javascript that opens a new window. when i call the javascript function i want to ad a variable. what you see on the pop up depends on the variable. but the variable in...
5
by: John Warner | last post by:
I have a wierd problem that I can't find any reference to in the knowledge base. I develop simple databases at the company where I work, and many of them are used by hundreds of employees. We all...
2
by: Colin Nicholls | last post by:
Platform: ASP.NET 1.1 I have a repeater nested inside another repeater. My outer repeater is looping fine. I am manually binding the inner repeater to a DataReader obtained from another...
7
by: simon | last post by:
I have simple html(aspx) page, but vertical height won't work. Even if i had set the height of a table=100%, the table is not 100% height. I spend a lot of time(my real page is more...
30
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the...
0
by: clintonG | last post by:
The Wizard is on Step5 and some TextBox validation in Step5 has to be done on the server so I've been thinking I need to use the OnActiveStepChanged event. This server-side validation has to be...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
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: 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: 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
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,...
0
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...
0
agi2029
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,...

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.