473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

String Reading

2
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!
Feb 29 '08 #1
3 1692
Stewart Ross
2,545 Expert Mod 2GB
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
Mar 1 '08 #2
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Dim varListContents As Variant, intCounter As Integer
  2.  
  3. varListContents = Split(Me![List1].RowSource, ";")
  4.  
  5. 'Read the contents of the Array back
  6. For intCounter = LBound(varListContents) To UBound(varListContents)
  7.   Debug.Print varListContents(intCounter)
  8. Next
Mar 1 '08 #3
gav82
2
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:
Expand|Select|Wrap|Line Numbers
  1. Dim varListContents As Variant, intCounter As Integer
  2.  
  3. varListContents = Split(Me![List1].RowSource, ";")
  4.  
  5. 'Read the contents of the Array back
  6. For intCounter = LBound(varListContents) To UBound(varListContents)
  7.   Debug.Print varListContents(intCounter)
  8. Next

Split works a treat thanks a lot guys, just for the record I wanted the (;) as a delimiter so thats great.

Thanks
Mar 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
19
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...
8
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...
32
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...
18
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...
37
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...
53
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;
3
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 ). ...
7
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,...
4
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
1
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)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.