# Listbox entering a leading space

**URL:** <https://forum.xojo.com/t/listbox-entering-a-leading-space/34515>\
**Category:** General\
**Created:** [November 16, 2016, 4:36pm UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515 "2016-11-16T16:36:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Schlam](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/46a35a/32.png) [@David\_Schlam](https://forum.xojo.com/u/David_Schlam)\
**Post date:** [November 16, 2016, 4:36pm UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515/1 "2016-11-16T16:36:00Z")

</div>

I have a listbox where one record has a leading space (maybe two) on one cell (first\_name). No other cells have this problem.

The data is being fed by a postgres 9.1 database with a simple command:

```auto
lb.AddRow(rs.Field("PtNumber").StringValue,rs.Field("LastName").StringValue,rs.Field("FirstName").StringValue)
```

I check the data in pgAdmin3 and Navicat and both show no leading spaces in the first\_name column.

I am guessing that somehow an extraneous non-visible character (in pgAdmin3 and Navicat) was somehow entered that Xojo is showing as a space.

Neither re-entering the field nor performing a Trim on the field seems to fix this.

Any ideas on how to find out if this is correct and possibly correct this?

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [November 16, 2016, 4:40pm UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515/2 "2016-11-16T16:40:33Z")

</div>

do this as a test

```auto
dim s as string=rs.Field("FirstName").StringValue
break
```

then examine the value of s using the debugger to see what is really there (hex wise)

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [November 16, 2016, 6:29pm UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515/3 "2016-11-16T18:29:07Z")

</div>

Apply Trim:

```auto
lb.AddRow(rs.Field("PtNumber").StringValue.Trim
```

Or use a database editor and sort the table by first name so that the suspected records appear on top and then correct the values manually.

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [November 16, 2016, 7:32pm UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515/4 "2016-11-16T19:32:19Z")

</div>

> [@298726:@Eli Ott](#):
>
> Apply Trim:

He already mentioned that didn’t solve the problem

> [@298714:@David Schlam](#):
>
> Neither re-entering the field nor performing a Trim on the field seems to fix this.

---

<div class="post-metadata">

**Author:** ![David\_Schlam](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/46a35a/32.png) [@David\_Schlam](https://forum.xojo.com/u/David_Schlam)\
**Post date:** [November 17, 2016, 11:22am UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515/5 "2016-11-17T11:22:28Z")

</div>

[quote=298715:@Dave S]do this as a test

dim s as string=rs.Field(“FirstName”).StringValue  
break  
then examine the value of s using the debugger to see what is really there (hex wise)[/quote]  
Interestingly enough, what this turned out to be was I was looking at the wrong table. This is a very old database that was ported over. The original design used the name in more than one table. I know better now.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:33pm UTC](https://forum.xojo.com/t/listbox-entering-a-leading-space/34515/6 "2020-10-29T18:33:24Z")

</div>


