178 views

calculating value in listbox

1. 4 months ago

Arief S

Apr 23 Bandung - Indonesia

Hi,
I was trying to calculate value in a listbox's cell, no error shows, but it wont work,

```  dim ox as integer
for ox=0 to ListBox1.Listcount-1
dim g as integer
g=val(Listbox1.cell(ox,7))

if  g<=100000 then
if g>0 then
Listbox1.cell(ox,14)=str(val(Listbox1.cell(ox,6))*1000)
end if
end if
next```

without this line its worked, ` if g>0 then`
but i want to calculate it, if the columns not empty or zero

anything that i missed ?

thanks
regards,
arief

Answered by Joost R

See post in context

I prefer having a reference to an existing object of a representive type according to the listbox columns , stored in the rowtag of each row, and have all properties in their logical type-format. You prevent a lot of listbox issues while populating, storing and editing.

2. Emile S

Apr 23 Europe (France, Strasbourg)

@Arief S but i want to calculate it, if the columns not empty or zero

Check directly if the Cell is empty (or not)…

`If Listbox1.cell(ox,7) = "" Then // Empty Cell`

You can also check if the Cell contents is a number…

`If IsNumeric(Listbox1.cell(ox,7) Then // true if value is numeric`

Check syntax.

3. Stéphane M

Apr 23 France

@Arief S — Just a quick tip, since you get started with Xojo. You can join the Dim and For statements like this:

`for i as Integer=0 to ...`

The only difference is that the loop variable will be valid within the loop only

4. Bob K

Apr 23 Pre-Release Testers, Xojo Pro Kansas City

I think you want:

`if g = 0 then`

Since g=val(Listbox1.cell(ox,7)) will be zero if the cell is blank.

5. Joost R

Apr 23 Pre-Release Testers, Xojo Pro Answer The Netherlands

I prefer having a reference to an existing object of a representive type according to the listbox columns , stored in the rowtag of each row, and have all properties in their logical type-format. You prevent a lot of listbox issues while populating, storing and editing.

6. Arief S

Apr 23 Bandung - Indonesia

Hi,

Thanks for all the helps,

its worked now.

regards,
arief