# Is WebListBox.CellValueAt String or Variant?

**URL:** <https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947>\
**Category:** Web\
**Created:** [January 12, 2022, 5:02pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947 "2022-01-12T17:02:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marius\_Dieter\_Noetzel](https://forum.xojo.com/user_avatar/forum.xojo.com/marius_dieter_noetzel/32/661_2.png) [@Marius\_Dieter\_Noetzel](https://forum.xojo.com/u/Marius_Dieter_Noetzel)\
**Post date:** [January 12, 2022, 5:02pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/1 "2022-01-12T17:02:58Z")

</div>

After I tried to open an old web-project with newer Xojo (web1-\>web2) I saw the documentation:

> **CellValueAt** (Row As [Integer](https://documentation.xojo.com/api/data_types/integer.html), Column As [Integer](https://documentation.xojo.com/api/data_types/integer.html)) **As** [String](https://documentation.xojo.com/api/data_types/string.html)

While Xojo itself mentioned:

> (2, 60) WebListBox.CellValueAt(Row as Integer, Column as Integer) As Variant

Is that a problem with the docs?

Marius

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [January 12, 2022, 6:09pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/2 "2022-01-12T18:09:07Z")

</div>

I think **CellValueAt** is overloaded:

```auto
Function CellValueAt(Row as Integer, Column as Integer) As Variant
Sub CellValueAt(Row as Integer, Column as Integer, Assigns Value as String)
Sub CellValueAt(Row as Integer, Column as Integer, Assigns Value as WebListboxCellRenderer)

```

---

<div class="post-metadata">

**Author:** ![Marius\_Dieter\_Noetzel](https://forum.xojo.com/user_avatar/forum.xojo.com/marius_dieter_noetzel/32/661_2.png) [@Marius\_Dieter\_Noetzel](https://forum.xojo.com/u/Marius_Dieter_Noetzel)\
**Post date:** [January 13, 2022, 2:56pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/3 "2022-01-13T14:56:02Z")

</div>

Overloaded by MBS-Plugins?  
So your plugins change the way that works like it is documented??? 🤨

If Xojo is using String for Cell-Fields (everywhere else), why should that be changed to variant?  
If CellValueAt returns Variant, shouldn’t there be Autocomplete for “.StringValue”, “.IntegerValue” etc?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [January 13, 2022, 2:58pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/4 "2022-01-13T14:58:50Z")

</div>

Not overloaded by plugin although a method in a module (plugin or project) can add something there.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [January 13, 2022, 3:08pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/5 "2022-01-13T15:08:08Z")

</div>

It returns a variant. The return value can either be a string or a custom cell instance.

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter](https://forum.xojo.com/user_avatar/forum.xojo.com/manfred_richter/32/587_2.png) [@Manfred\_Richter](https://forum.xojo.com/u/Manfred_Richter)\
**Post date:** [February 13, 2022, 1:51pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/6 "2022-02-13T13:51:40Z")

</div>

Is it possible to read the content from such a custom cell instance. This might solve my problem to read the format of the cell.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [February 13, 2022, 3:28pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/7 "2022-02-13T15:28:08Z")

</div>

Sure. If you convert the value to a string, it’ll be a serialized json representation of the cell.

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter](https://forum.xojo.com/user_avatar/forum.xojo.com/manfred_richter/32/587_2.png) [@Manfred\_Richter](https://forum.xojo.com/u/Manfred_Richter)\
**Post date:** [February 13, 2022, 9:45pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/8 "2022-02-13T21:45:41Z")

</div>

This worked with 2021r1.1. But with the later versions I get an exception when I try to read the value.

In this example the cell is a styled cell

Dim T2 as Variant  
Dim AktGesamt As Dictionary

T2 = ListBox1.CellValueAt( 0,1)  
AktGesamt = JSONItem( T2)

The assignment to T2 works. But as soon as I try to read the content I get an exception. If T2 would be of type String and contains the JSON it should work. But I have no idea to cast the variable so I could decode it.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [February 13, 2022, 11:07pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/9 "2022-02-13T23:07:24Z")

</div>

The code you’ve got there is probably going to throw an IllegalCastException I think. You really ought to be checking if `T2 IsA JSONItem` before casting it like that.

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter](https://forum.xojo.com/user_avatar/forum.xojo.com/manfred_richter/32/587_2.png) [@Manfred\_Richter](https://forum.xojo.com/u/Manfred_Richter)\
**Post date:** [February 14, 2022, 7:10am UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/10 "2022-02-14T07:10:40Z")

</div>

Hello,

this example should be as simple as possible. So I didn’t add this part of code.

I investigated a little bit.

The problem seems to be that CellValueAt return a type 9 (Object) and JSONItem need a String value. So it raises a TypeMismatchException. Maybe a change of the return type to String would solve the problem.

BTW: 2021R1.1 returns a type String.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [February 14, 2022, 12:56pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/11 "2022-02-14T12:56:11Z")

</div>

> [@Manfred\_Richter](#):
>
> The problem seems to be that CellValueAt return a type 9 (Object)

Did you check to see if that object IsA JSONItem?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 14, 2022, 1:26pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/12 "2022-02-14T13:26:02Z")

</div>

To help make that more clear:  
[https://documentation.xojo.com/api/language/isa.html#isa](https://documentation.xojo.com/api/language/isa.html#isa)

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@Manfred\_Richter1](https://forum.xojo.com/u/Manfred_Richter1)\
**Post date:** [February 14, 2022, 2:09pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/13 "2022-02-14T14:09:49Z")

</div>

Hello,

I added the if statement. but the return value is not an JSONItem.

T1 = ListBox1.CellValueAt( 0,0)  
T2 = ListBox1.CellValueAt( 0,1)  
aktType = T2.Type '8 with 2021R1.1 and 9 with 2022R1  
If T2 IsA JSONItem Then  
AktWerte = ParseJSON( T2)  
End If

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@Manfred\_Richter1](https://forum.xojo.com/u/Manfred_Richter1)\
**Post date:** [February 14, 2022, 2:18pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/14 "2022-02-14T14:18:43Z")

</div>

I loaded my example project to

[https://beta.mcrichter.de/TestGetCellValue.zip](https://beta.mcrichter.de/TestGetCellValue.zip)

I hope this makes all a little bit more clear.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 14, 2022, 2:28pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/15 "2022-02-14T14:28:37Z")

</div>

`ParseJSON(variable)` and `JSONItem(variable)` do different things.

ParseJSON is a function that accepts a string and returns a JSONItem. [Documentation Link](https://documentation.xojo.com/api/text/json/parsejson.html#parsejson)  
JSONItem(variable) is casting the object to a JSONItem. [Documentation Link](https://documentation.xojo.com/getting_started/object-oriented_programming/advanced_oop_features.html#getting-started-object-oriented-programming-advanced-oop-features-casting)

In your example project you’re checking T2, but it’s _not_ a `JSONItem` so the code is correctly skipping that part. What exactly are you trying to do? Tell us your goal, and we may be able to help you find the best direction.

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@Manfred\_Richter1](https://forum.xojo.com/u/Manfred_Richter1)\
**Post date:** [February 14, 2022, 3:02pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/16 "2022-02-14T15:02:02Z")

</div>

I wants to parse the JSON to get for example the value of the cell.

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter](https://forum.xojo.com/user_avatar/forum.xojo.com/manfred_richter/32/587_2.png) [@Manfred\_Richter](https://forum.xojo.com/u/Manfred_Richter)\
**Post date:** [February 14, 2022, 3:37pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/17 "2022-02-14T15:37:49Z")

</div>

JSONItem(variable) has no parameter, beside a string one. So I can’t enter the returned JSON. And because the Return value of CellValueAt is Object I can’ cast it to a JSON.

I see no way in Xojo for a forced casting as in other languages.

---

<div class="post-metadata">

**Author:** ![Marius\_Dieter\_Noetzel](https://forum.xojo.com/user_avatar/forum.xojo.com/marius_dieter_noetzel/32/661_2.png) [@Marius\_Dieter\_Noetzel](https://forum.xojo.com/u/Marius_Dieter_Noetzel)\
**Post date:** [February 14, 2022, 4:14pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/18 "2022-02-14T16:14:35Z")

</div>

I can’t see what this Problem hast to do with a json-item. But it seems to be a Problem.  
WebListbox.CellValueAt should NOT return a WebListBoxStyleRenderer-Object (where the value is NOT accessible), it should return the CellValue.  
I can’t see why this should be a question of json. Even if this object might be json internally.

---

<div class="post-metadata">

**Author:** ![Manfred\_Richter](https://forum.xojo.com/user_avatar/forum.xojo.com/manfred_richter/32/587_2.png) [@Manfred\_Richter](https://forum.xojo.com/u/Manfred_Richter)\
**Post date:** [February 14, 2022, 4:31pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/19 "2022-02-14T16:31:59Z")

</div>

When I bring all informations together it is possible that only the type of the return value is wrong. With 2021r1.1 it was String and now Object.

Greg, can you look if this is the problem? And when yes, can you change it.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [February 14, 2022, 9:05pm UTC](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947/20 "2022-02-14T21:05:37Z")

</div>

> [@Manfred\_Richter1](#):
>
> I wants to parse the JSON to get for example the value of the cell.

Your example project did not have JSON in the cell, and a WebListbox cell is a really awkward place to find JSON strings – so I was not certain what you wanted.

To turn a string into a JSONItem you need to load the string in somehow, you can’t cast the string to JSONItem (though that would be cool). There are two ways to do so. [You can create the JSONItem and then Load the string in](https://documentation.xojo.com/api/text/json/jsonitem.html#api-text-json-jsonitem-load) or [you can pass the string to the Constructor.](https://documentation.xojo.com/api/text/json/jsonitem.html#api-text-json-jsonitem-constructor2)

Passing a string to the constructor of JSONItem looks very similar to casting it, however you’ll notice the keyword “new” is what constructs the item calling the constructor. This is _different from_ casting an object.

Edit: And, of course, if you’re getting a WebListboxCellRenderer back, you’ll need to build your own system of getting the “value” – whatever that may be for your cell.

[Next page](https://forum.xojo.com/t/is-weblistbox-cellvalueat-string-or-variant/67947.md?page=2)
