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

Working with List Boxes

I have a question about list boxes...How do you "add" or "subtract" the items in a list box?

For an example: You output the numbes 5 and 10 to your listbox, how do you add those two numbers and then output it to a text box???
Nov 16 '07 #1
3 1266
Killer42
8,435 Expert 8TB
I have a question about list boxes... How do you "add" or "subtract" the items in a list box?

For an example: You output the numbers 5 and 10 to your listbox, how do you add those two numbers and then output it to a text box?
You would just access each entry of interest, and convert it to a number. The details will vary a bit, depending on what version of VB you're using (hint hint...)
Nov 16 '07 #2
QVeen72
1,445 Expert 1GB
Hi,

Try this :

Expand|Select|Wrap|Line Numbers
  1. Dim TNo as Single
  2. Dim i As Integer
  3. TNo = 0
  4. For i =0 To List1.ListCount -1
  5.     TNo = TNo + Val(List1.List(i))
  6. Next
  7. MsgBox "Total Is : " & TNo
  8.  
Regards
Veena
Nov 16 '07 #3
Mohan Krishna
115 100+
Hi Purplelair,

Hope this would help you. But you have to improvise as per your requirement.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim a(100), i, sum As Integer
  3.  
  4. Private Sub Command1_Click()
  5.     i = i - 1
  6.     While i >= 0
  7.         sum = sum + a(i)
  8.         i = i - 1
  9.     Wend
  10.     Text2.Text = sum
  11.     sum = 0
  12.     i = 0
  13. End Sub
  14.  
  15. Private Sub Command2_Click()
  16.     If List1.SelCount > 2 Then
  17.         MsgBox "Select only Two Numbers! Try Again"
  18.         'List1.SelCount = -1
  19.         Exit Sub
  20.     End If
  21.     Text3.Text = a(0) - a(1)
  22.     List1.Clear
  23. End Sub
  24.  
  25. Private Sub Form_Load()
  26.     i = 0
  27.     sum = 0
  28. End Sub
  29.  
  30. Private Sub List1_Click()
  31.     a(i) = List1.List(List1.ListIndex)
  32.     i = i + 1
  33. End Sub
  34.  
  35. Private Sub Text1_LostFocus()
  36.     List1.AddItem (Text1.Text)
  37.     Text1.Text = ""
  38. End Sub

All the Best! Please respond...
Nov 16 '07 #4

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

Similar topics

0
by: Dwayne Gaddy | last post by:
Hey all, I have a windows form with a list boxes. I have data bound the list boxes with data from my sql database. I want to use drag and drop to allow users to choose different options from the...
1
by: tim | last post by:
Is there like an easy way to make file boxes? You know the type, kinda like a file explorer where I can select a file for processing? In visual basic it was simple with the file list boxes, and the...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
3
by: sewerized | last post by:
Hello all, I'm having a problem with a user preferences form I'm creating. I want to use dynamic dropdown SELECT boxes for this so my page doesn't get cluttered with 100000 links. Since I...
7
by: ljungers | last post by:
Have Form-1 with 3 text boxes and 1 command button. With any of the 3 boxes filled out and button is clicked, a Macro is performed that Opens a Query that has a WHERE clause that uses the 3 test...
3
by: ljungers | last post by:
Have a couple of conditions going on that I can't seem to get working correctly. Have 1 Form only with 3 text boxes that are used in a query, when a command button is clicked using 'Event...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
3
by: rudeman76 | last post by:
Hello, I am working on an incident form. I have 4 set text boxes and up to 4 drop-down boxes on the form. The user enters in the date then time. I have 4 option buttons for the user to select...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a menu contol on a master page and some dropdown boxes and text boxes on another page that gets loaded into the place holder of the master page. The dropdown menu on the master page...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
jinu1996
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...

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.