473,324 Members | 2,268 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,324 software developers and data experts.

Help with Arrays

I have a predefined array that looks something like

Private RemoveWords() As String = {"a", "b", "c"

and I want to take an input string, and remove the words from the string that are in the "RemoveWords" array. So basically if my string was "Walk a dog" it would return "Walk dog"

I tried doing something like
Dim tempArray() As String = inputString.Split(" "

For Each tempArray In RemoveWord
' Not sure what goes in here ye
Nex

but for the RemoveWords I get an error that says "value of type 'String' cannot be converted to '1-dimensional array of String'.

I haven't worked with arrays hardly at all, so I'm not really sure how to do this. Can anybody point me in the right direction

Thanks
Jeremy
Nov 18 '05 #1
3 965
Jeremy,

Looks like you need a nested loop. The outer loop iterates through the
values in tempArray() (each iteration containing current value in stSource).
The inner loop iterates through each value in RemoveWords() (each iteration
containing current value in stRemove).

'--------------------
' Revised loop code:
'--------------------
For Each stSource As String In tempArray
For Each stRemove As String In RemoveWords
' Within this loop, compare each stRemove (a String) value against
' value of stSource, the current word of tempArray
Next stRemove
Next stSource

Hope this helps,

--- JimM ---
"Jeremy" <an*******@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
I have a predefined array that looks something like:

Private RemoveWords() As String = {"a", "b", "c"}

and I want to take an input string, and remove the words from the string that are in the "RemoveWords" array. So basically if my string was "Walk a
dog" it would return "Walk dog".
I tried doing something like:
Dim tempArray() As String = inputString.Split(" ")

For Each tempArray In RemoveWords
' Not sure what goes in here yet
Next

but for the RemoveWords I get an error that says "value of type 'String' cannot be converted to '1-dimensional array of String'."
I haven't worked with arrays hardly at all, so I'm not really sure how to do this. Can anybody point me in the right direction?
Thanks,
Jeremy

Nov 18 '05 #2
Thanks Jim, that helps a lot

Jeremy
Nov 18 '05 #3
The Split method of a String returns an Array of Strings. In your array of
"RemoveWords" you have strings. However, in your "For" statement, you're
assigning an array of strings to the Item in the array, which is a string.
Try:

Private RemoveWords() As String = {"a", "b", "c"}
Dim s As String
For Each s In RemoveWords
' etc
Next

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jeremy" <an*******@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
I have a predefined array that looks something like:

Private RemoveWords() As String = {"a", "b", "c"}

and I want to take an input string, and remove the words from the string that are in the "RemoveWords" array. So basically if my string was "Walk a
dog" it would return "Walk dog".
I tried doing something like:
Dim tempArray() As String = inputString.Split(" ")

For Each tempArray In RemoveWords
' Not sure what goes in here yet
Next

but for the RemoveWords I get an error that says "value of type 'String' cannot be converted to '1-dimensional array of String'."
I haven't worked with arrays hardly at all, so I'm not really sure how to do this. Can anybody point me in the right direction?
Thanks,
Jeremy

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
8
by: inkexit | last post by:
I am a very amatuer c++ programmer and a somewhat accomplished composer. I am trying to write some code that creates 'self similar' melodies from a base melody the user inputs. This musical idea...
1
by: Geoff | last post by:
I was wondering if anyone could help me with a problem I am having. I am trying to read in a list of numbers from a file and then sort them using pointers and malloc() and free(). I know how to...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
110
by: fjm | last post by:
For some reason, I have always had a hard time understanding arrays as they pertain to php and databases. I understand associative arrays just fine but when there are multidimensional arrays, I kinda...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.