# calculating value in listbox

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

[code] 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[/code]
``````

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

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.

@Arief Sarjono  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

I think you want:

``if g = 0 then``

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

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.

Hi,

Thanks for all the helps,

its worked now.

regards,
arief