English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

hi , is there a way to create column in list box and picture box in vb6 so i can do calculation using the columns i also dont know code for that as well

example of what i want
colum1 , colum2 sum
QTY Price
2 5 10

so when i enter qty and price m it will be calculated automatically
please help

thank you

2006-12-23 10:38:47 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

The list box doesn't have specific columns. If you want an Excel like display you would use MSGrid.

For automatice calculation you need to trigger computation on an event like leaving focus of a text box.


There are ways to display text information in a list box so as to line up and appear to be in columns. To do this requires string formatting of data so each of your data fields ALWAYS have the same number of characters. This is done by padding with spaces.

Next you cannot use a proportionally spaced font and expect the fields to line up. In a proportional spaced font the pixel display width of charaters is different. (So in a list of seven letter words the width width size will change based on the spelling
You need to use a fixed font like "Courier New", this font all characters are the same width. (So in a list of seven letter words each word will be the same pixel width no matter how it was spelled)

You can make several PUBLIC pad routines in a MODULE
PadL - Pad Left
PadR - Pad Right
PadC - Center Text Pad Left and Right

Make a function:
Public Function PadL(txt as string, num as integer) as String

Code a function which receives a string to be padded called txt and a number which is the overall lenght of the string. The function will determine the original lenght of txt and add spaces if necessary to the left of text to make its character lenght equal to the value of num .

Once you make these functions you can assemble standardized lenght data fields with tab delimiters

So your original code which loads a string str into the list box:

str = column1.text & column2.text
listbox1.additem str

would become:

str = (padL(column1.text,25) )& vbTab & (padL(column2.text,25))
listbox1.additem str


To extract data from a list box line you can use the vbTab as the delimiter character and use the split function to load a string array. Then use the trim function to remove the leading and trailing spaces.

2006-12-24 03:10:59 · answer #1 · answered by MarkG 7 · 1 0

If you want to have multiple values to be a single entry in your list box using a space here are the 2 methods I can think of: 1) Send the ASCII value for space (32) in between your values. example: lstListbox.AddItem txtText1.Text & Chr(32) & txtText2.Text 2) Concatenate a space between values example: lstListbox.AddItem txtText1.Text & " " & txtText2.Text

2016-05-23 02:39:01 · answer #2 · answered by Anonymous · 0 0

How about something like:

lblPrice=intCost*intQuantity

something to that effect should work, not sure how much you need to know

2006-12-23 12:30:57 · answer #3 · answered by Anonymous · 1 0

fedest.com, questions and answers