Hi,
I'm new to Access and was wondering if someone could help me with a little problem.
If I am trying to get strings from an unbound listbox on a form and assign them to an array. How do I go about constructing the character reader in VBA to assign each string to an array element. I'm assuming that I need to read the row source and read each string up to a semicolon then repeat?
Any Help would be great as I am bamboozled thanks!
3 1692
Hi,
I'm new to Access and was wondering if someone could help me with a little problem.
If I am trying to get strings from an unbound listbox on a form and assign them to an array. How do I go about constructing the character reader in VBA to assign each string to an array element. I'm assuming that I need to read the row source and read each string up to a semicolon then repeat?
Any Help would be great as I am bamboozled thanks!
Hi Gav82. There is not enough detail in your post to give you an answer to your question at the moment. What is the source data for the listbox? What is the significance of the semicolon you mention? Are you including multiple elements in each string (not a good idea if you are...)? What is the purpose of the array? How many elements does it contain? What is going to be done after you fill the string array?
Please give us something more to help us answer you...
Regards
Stewart
Hi,
I'm new to Access and was wondering if someone could help me with a little problem.
If I am trying to get strings from an unbound listbox on a form and assign them to an array. How do I go about constructing the character reader in VBA to assign each string to an array element. I'm assuming that I need to read the row source and read each string up to a semicolon then repeat?
Any Help would be great as I am bamboozled thanks!
It's a lot simpler than you think, only 6 lines of code including a Comment. Assuming your List Box Name is List1, and that the Row Source Type is Value List, since you did mention the semi-colon, then: -
Dim varListContents As Variant, intCounter As Integer
-
-
varListContents = Split(Me![List1].RowSource, ";")
-
-
'Read the contents of the Array back
-
For intCounter = LBound(varListContents) To UBound(varListContents)
-
Debug.Print varListContents(intCounter)
-
Next
It's a lot simpler than you think, only 6 lines of code including a Comment. Assuming your List Box Name is List1, and that the Row Source Type is Value List, since you did mention the semi-colon, then: -
Dim varListContents As Variant, intCounter As Integer
-
-
varListContents = Split(Me![List1].RowSource, ";")
-
-
'Read the contents of the Array back
-
For intCounter = LBound(varListContents) To UBound(varListContents)
-
Debug.Print varListContents(intCounter)
-
Next
Split works a treat thanks a lot guys, just for the record I wanted the (;) as a delimiter so thats great.
Thanks
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hal Vaughan |
last post by:
If I have a byte and I convert it to string (String sData = new
String(byte bData), then convert it back (byte bData = sData.getBytes()),
will all data be intact, or do Strings have problems with...
|
by: Lionel B |
last post by:
Greetings,
I need to read (unformatted text) from stdin up to EOF into a char
buffer; of course I cannot allocate my buffer until I know how much
text is available, and I do not know how much...
|
by: Eric Lilja |
last post by:
Hello, I had what I thought was normal text-file and I needed to locate a
string matching a certain pattern in that file and, if found, replace that
string. I thought this would be simple but I had...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: Ger |
last post by:
I have not been able to find a simple, straight forward Unicode to ASCII
string conversion function in VB.Net.
Is that because such a function does not exists or do I overlook it?
I found...
|
by: Vadim |
last post by:
Hi!
I have a STL string, which I need to convert to low case.
In VC 6 I used:
string sInputBuffer = _strlwr((char*)sBuffer.c_str());
However, now in MSVC.NET 2005 I am getting a warning, that...
|
by: Jeff |
last post by:
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
by: psbasha |
last post by:
Hi ,
When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ).
...
|
by: random guy |
last post by:
Hi,
I'm writing a program which creates an index of text files. For each
file it
processes, the program records the start and end positions (as
returned by
tellg()) of sections of interest,...
|
by: dacuteangel04 |
last post by:
ok what my program is suppost to do is open a file - Grades.txt and read each line the breaking the lines down w/ tokens so i may later average some numbers
an example some of the lines from the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |