473,797 Members | 2,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bound text box

Rob
Assume 3 controls on a form....

Textbox1, Textbox2, and Textbox3

If you want Textbox3 to equal Val(Textbox1) + Val(Textbox2)..

How do you hardcode this to Textbox3 ?
Dec 27 '05
16 2229
Rob
Thank you both for responding...

Here is the situation....

I am coming from MS-Access where you may bind a formula directly to a text
box...

What the user's like about this approach (in a Quote providing application)
is that they do not have to do anything to see a "Total" on the form... the
Total gets created as the user add components....

So in Access, you can code such that if the texbox is null, don't show a
total, otherwise, let them see the $ amount... without having to click a
button.

As far as programming goes... I would like to have an "Update Total" button,
but do not know how user's will like that....
"Homer J Simpson" <no****@nowhere .com> wrote in message
news:vwntf.2559 6$OU5.24963@clg rps13...

"Scott M." <s-***@nospam.nosp am> wrote in message
news:uz******** *****@TK2MSFTNG P12.phx.gbl...
The code I gave him was the simplest possible solution and it worked.
From that he can add as much complication as he desires. KISS.


You think writing the same code in 2 different places is the simpleset
solution? Uh, well ok.

As I said earlier, it's really a matter of choosing between TextChanged
and a button's Click event handler (as you say, they both work) but there
are those who believe (me among them) that you should give the user a
control to interact with in order for an operation to be triggerd.

Both scenarios are simplistic, it's a usability issue (and with my
solution, there is less code to add).


You'll never get it.

Dec 31 '05 #11
I hear what you are saying, but although you may find the automatic
calculation connected directly to the textbox a nice feature, general
usability standards would say you should have a button to perform the
operation (or at least a button in addition to the automatic calculation).

It is certainly possible (as I've said) to attach your code to the
TextChanged event of the textboxes and then have each event handler call a
dedicated routine to do the operation. That's not *wrong*. I'm merely
saying that there are certain aspects of a well-created UI that should be
given consideration and having a button to click is one of them.
"Rob" <rw*****@comcas t.net> wrote in message
news:Ss******** *************** *******@comcast .com...
Thank you both for responding...

Here is the situation....

I am coming from MS-Access where you may bind a formula directly to a
text box...

What the user's like about this approach (in a Quote providing
application) is that they do not have to do anything to see a "Total" on
the form... the Total gets created as the user add components....

So in Access, you can code such that if the texbox is null, don't show a
total, otherwise, let them see the $ amount... without having to click a
button.

As far as programming goes... I would like to have an "Update Total"
button, but do not know how user's will like that....
"Homer J Simpson" <no****@nowhere .com> wrote in message
news:vwntf.2559 6$OU5.24963@clg rps13...

"Scott M." <s-***@nospam.nosp am> wrote in message
news:uz******** *****@TK2MSFTNG P12.phx.gbl...
The code I gave him was the simplest possible solution and it worked.
From that he can add as much complication as he desires. KISS.

You think writing the same code in 2 different places is the simpleset
solution? Uh, well ok.

As I said earlier, it's really a matter of choosing between TextChanged
and a button's Click event handler (as you say, they both work) but
there are those who believe (me among them) that you should give the
user a control to interact with in order for an operation to be
triggerd.

Both scenarios are simplistic, it's a usability issue (and with my
solution, there is less code to add).


You'll never get it.


Dec 31 '05 #12
> You'll never get it.

Not if you don't explain what it is you are trying to say, I won't. You
stated that your solution was the simplest possible one, and then touted the
KISS principal as if what I showed was somehow rocket science. You and I
showed the same thing. The only difference is that you put your code in 2
places and have it being invoked from the TextChanged event and I put it in
one place and have it being invoked from a button's Click event.

Now, tell me again how your solution is the simplest and what it is that I
don't get?
Dec 31 '05 #13

"Scott M." <s-***@nospam.nosp am> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
You'll never get it.
Not if you don't explain what it is you are trying to say, I won't. You
stated that your solution was the simplest possible one, and then touted
the KISS principal as if what I showed was somehow rocket science. You
and I showed the same thing. The only difference is that you put your
code in 2 places and have it being invoked from the TextChanged event and
I put it in one place and have it being invoked from a button's Click
event.

Now, tell me again how your solution is the simplest and what it is that I
don't get?


You are in an education mode. This user requires the simplest possible
solution. Once he sees it working he can add whatever complication or
enhancements he desires. This is how to teach:-

First, show him a bubble sort. Demonstrate that it works.
Second, show him how slowly it works.
Third, show him a Shell sort. Now he understands.

BTW, a one line routine is not optimized for speed or size by calling it as
a subroutine instead of running inline.

Dec 31 '05 #14
> You are in an education mode. This user requires the simplest possible
solution. Once he sees it working he can add whatever complication or
enhancements he desires.
I'll ask you again (third time) how puting the code in two different places,
rather than just one is the simplest possible solution? Since your code and
mine are the same, the only difference becomes where it is put and how much
coding is involved. Your code works perfectly fine, but requires more code
to make it work (and more maintenance if the calculation were to change), so
what is it that you believe is simpler than one line of code:

TextBox3.Text = TextBox1.Text & TextBox2.Text

Really, step off your high horse for a second and think about this. This is
ONE line of code put in ONE place - - seems pretty darn simple to me.
This is how to teach:-

First, show him a bubble sort. Demonstrate that it works.
Second, show him how slowly it works.
Third, show him a Shell sort. Now he understands.
Thanks for the tip. Since I own and operate a technology training company
(TechTrainSolut ions.com) and have been doing IT education for 15 years and
assorted industry training for 10 years before that, I'll stick to my
methodology, which works exceptionally well thanks. It's based on
well-known education principals for teaching adults (which is different than
how you teach children).
BTW, a one line routine is not optimized for speed or size by calling it
as a subroutine instead of running inline.


That's not necessarially true. There are several reasons why repeating the
same calculation in more than one place is a bad idea, poor technique and
why just about every professional developer will tell you so:

1. It's not good because if the calculation/algorythm needs to change, you
have to change it in more than one place.
2. It's not good because you may miss one of the places it needs to be
updated.
3. It also opens the door to the possibility that the two (or more) lines
will inadvertently become different from each other, causing unexpected
results.

As for optimization, calling a method rather than doing the operation from
one within one method will have virtually no impact on performance. In
other words, contrary to your statement, a one line routine's performance is
not impacted by the fact that it needs to be called from another method.

It seems to me that you just want to argue no matter what is said. If you
believe your technique is better, great - use it. But, please don't make
claims that are incorrect and have no basis in fact.

Happy New Year!
Dec 31 '05 #15
By the way, your line of code:

TextBox3.Text = TextBox1.Text & TextBox2.Text

wouldn't produce the mathematical addition of the two values in either VB
6.0 or VB.NET, it would produce the concatenation of the two values.

The correct VB.NET statement is:

Textbox3.Text = CType(Textbox1. Text, Double) + CType(Textbox2. Text, Double)

The CType function calls are required because Option Strict should be turned
on at all times (you knew that, right?) and with Option Strict turned on,
you can't attempt to add Textbox values (or do any math at all) without
casting the value first.

-Scott
Dec 31 '05 #16
Correction:

Textbox3.Text = CType(CType(Tex tbox1.Text, Double) + CType(Textbox2. Text,
Double), String)
"Scott M." <s-***@nospam.nosp am> wrote in message
news:eT******** ******@TK2MSFTN GP09.phx.gbl...
By the way, your line of code:

TextBox3.Text = TextBox1.Text & TextBox2.Text

wouldn't produce the mathematical addition of the two values in either VB
6.0 or VB.NET, it would produce the concatenation of the two values.

The correct VB.NET statement is:

Textbox3.Text = CType(Textbox1. Text, Double) + CType(Textbox2. Text,
Double)

The CType function calls are required because Option Strict should be
turned on at all times (you knew that, right?) and with Option Strict
turned on, you can't attempt to add Textbox values (or do any math at all)
without casting the value first.

-Scott

Dec 31 '05 #17

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

Similar topics

0
1833
by: Paul Edwards | last post by:
I am writing in c# with Visual Studio 2003. I am creating a form that shows one record from a Dataset that is populated with only one record from SQL Server 2000. I am using bound controls, both text boxes and Combo Boxes (populated successfuly from same data source). When I use the fill command for the SQLDataAdaptor I can get the data by querying the dataset but the controls on the form do not show the data. If I set a combo box to...
4
2966
by: vulcaned | last post by:
Hi All, Hopefully I explain this well........ In Access97 I have a form which has a tab control on it, each tab has a sub-form which is bound to its appropriate table(I'll call them 'Detail' tables). I have a 'Header' table and fields from it are displayed on the form above the tab control. Header table name is tblClientInfo Detail tables are tblPolicyInfo, tblBeneInfo, tblRiderInfo
6
1583
by: BBM | last post by:
Hi, I'm having trouble getting control data binding to work. As I understand it, the simplest form of databinding requires three things: 1) A control (say a textbox) on a form or user control, 2) A field or object.member to which you want to bind, 3) A "Binding" object that connects the variable to a property of the control ("Text" for example).
9
424
by: Greg | last post by:
Binding Manager & dataset - won't add record I've got an untyped dataset with controls bound through code. The user can select a question number from a bound combobox, and the question number and question text are displayed in bound textboxes. This part works fine. When I go to add a new record, the textboxes clear as they should. I enter a new question number and tab to the textbox for the question text. At this point, the text for the...
7
4229
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source (DataBindings). - When I display a record and then try to access the .Text property of one of the text boxes on any tab except the current tab, the result is an Empty string.
6
11296
by: timbobd | last post by:
I have a Windows form that displays a database table in a DataGrid. When you click on a row, the row's values get copied to bound TextBoxes below, and when the "Save" button is clicked the database is updated (as is the DataGrid row) with changed values in the TextBoxes. Here are some observations: 1) When changes are typed into a text box and "Save" is clicked, the changes are reflected in the DataSet.Tables().Rows().ItemArray value, but...
4
4622
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
1
4869
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1 to limit what is displayed in bound combo box C2. When I display Tbl-A records on a continuous form, and navigate away from record 1 to record 2, the previously entered data displayed in C2 for record 1 disappears from
0
2018
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number of different screens down to a minimum, I'm trying to use the same Windows Forms for both browsing and for updating. This works fine for TextBoxes, but I'm running into problems with my DropDownLists (ComboBoxes).
0
2515
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. In this table there are multiple columns that cannot be NULL, which, are bound to other controls (but they're not really important at this time). I create a new row via the currency manager like so: _currencyManager.AddNew() _currentRow =...
0
9685
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, 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...
0
9536
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10021
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
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();...
0
5458
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...
1
4131
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
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
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...

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.