Strings - Singles Out Each Of These Words And Makes It Into An Array?
Jan 8, 2012i have a text document that is a list of words. How do i code using substring so that it singles out each of these words and makes it into an array?
View 14 Repliesi have a text document that is a list of words. How do i code using substring so that it singles out each of these words and makes it into an array?
View 14 RepliesC# or VB.NET suggestion are welcome.
I have the following code:
Dim someText = "Stack Over Flow Community"
Dim someWord = "Over Community"
[code].....
The code below replaces if it finds a given string from the list of contractions with its equivelant from the list of word-contractions. E.g., if it finds 'll it will replace it with Will. The code words but whtn it comes to let's it will replace it with let is.
'remove panctuation and contractions first
Dim contractions As List(Of String) = New List(Of String)(New String() _
{"'ll", "'re", "'ve", "'m", "'d", "'s", "n't", "won't", "lets", "let's", "ikon of elkomenos", "ikon of crucifixion", "ikon of crist elkomenos", "Part A", "Part B", "renaissance style", "hagios nikolaos", "full wall fortification"})
[code]....
I'm migrating from VB6 to VB.NET, in hence my questions below:
I have to write a function that returns array of strings.
How can I initiate it to empty array? I need it since I have to check if it's empty array after it returns from this function.
Is list of arrays better for this purpose? If I use a list - Is it empty when it firstly defined? How can I check it it's empty?
Dim str As String
Dim str2 As Array
str = "blabla duhduh"
str2 = str.Split(" ")
Dim result as single = 0
result = CType("8.01", Single) * 100 ' result=801.0 as expected
result = CType("8.02", Single) * 100 ' result=802.000061 --- not expected
Further to the above
result = 8.02 * 100 ' result = 802.0 as expected
I am tasked with the job of reading the X and Y coordinate of a Text label from a "save file" of a 2D CAD drawing. I found the exact position of the coordinates in the file, but I still don't understand how to read them 100%. They aren't simple ASCII characters.First, I read the file byte by byte, and load them into a textbox seperated by spaces as numbers from 0 to 255. Here is an example X and Y coordinate
View 1 RepliesI have a file - (called 38.dat) it contains a 3600 numbers (single) which are undelimited. This file cannot be read by notepad so is not in text format but saved a floating point numbers. how could i get VB.net to read the file and save the values to an array the size of 120 x 30?
View 1 RepliesIn VB.net I've got the following line that removes all non-alphanumeric chars from a string:
return Regex.Replace(build, "[W]", "")
I now need to extend this to remove non-alphanumeric chars that aren't [] or _. I've changed the line to:
return Regex.Replace(build, "[W[]_]", "")
However I'm pretty sure that this says
replace non-word or [ or ] or _
how do I negate the tests for the [] and _ chars so that it says
replace non-word and not [ and not ] and not _
Some examples:
"[Foo Bar_123456]" => "[FooBar_123456]"
"[Foo Bar_123-456*]" => "[FooBar_123456]"
how to convert an array of strings to an array of integers? I want to convert a string array with 77, all string numbers, to an integer array?
View 1 Repliesi have 2 string arrays and I want to merge them together then put the elements into a third string array ..
for an example :
string1="a","b","c"
string2="d","e","f"
after merging:
string3="a","b","c","d","e","f"
I'm attempting to setup a search function from a string a user types. (ex: "John Doe" or "Doe, John") I was thinking I would use Replace(SearchString, ",", "") to get rid of the commas the user might enter, and then use Split(SearchString, " ") to get all the words into an array. Once they're in the array I would execute a Stored Procedure on each of the terms and build a DataTable with the results.
Below is what I'm wanting to use for executing my stored procedure.
oCommand = DataAccess.GetSQLCommand("MyStoredProcedure", CommandType.StoredProcedure, SourceServer.ConnectionLocal)
oCommand.Parameters.AddWithValue("@MySearchString", SearchString)
[Code]....
Now I'm thinking the "SearchString" I will assign while looping through my array of words... but this doesn't seem like the right way to do this. Maybe it is but I don't know how to append my next result to the previous DataTable either.
How would you select a random word from an array list. Here is my coding:
'Create a sub which reads the words from the file and selects a random word.
Sub ReadWordsFromFile(ByVal fileName As String, ByRef RandomWord As String)
'Create a random number generator.
Dim RandomNumber As New Random
Dim words As New ArrayList
[Code]...
I have a textbox which has about 120 lines of text but this can vary. I want to search for an array of words, like Boeing, Airbus, Saab etc there might be 3 options there might be 5 options in this array that i'm looking for. My question is how can I search the textbox and highlight all these words? Similar to (Control + F) in IE8. I've looked at InStr but am unsure if this is what I'm after as it does not seem to work for me.
View 4 RepliesI am in a "survey of programming languages" course and have a professor who doesn't teach. There is no text book for this course.I am working a VB Form project to take a URL, grab the HTML source code, parse out all words, and count the occurrences of each word on the page. I have built the form, and written the code to parse the words and store them in an array. What is the most efficient way to count the occurrences of each individual word in that array (case insensitive), sort the results decreasing from most frequent, and display the results of the ten most used words. I will be displaying the results in two separate listboxes on my form. 1 listbox shows the words, and the other shows the number of occurrences.
View 17 RepliesI have a situation where a user can enter just about anything they want into a text box.Whatever they enter in the box, I need to split the string into an array of strings where each item is one word. For example, if the user enters All State Insurance, I split that into a string array:
sParams(0) = "All"
sParams(1) = "State"
sParams(2) = "Insurance"
[code]....
Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?
View 2 RepliesI'm trying to read lines from a file and split them into two words contained in a two dimensional array. The file looks something like this:
dog cat
red blue
orange green
night day
[code]....
'When I run it, it highlights the following line and says Object reference not set to an instance of an object
pos(i, 0) = value(0)
pos(i, 1) = value(1)
i = i + 1
Loop
[code]....
why I'm getting this error?
If I want to store a list of names ie. "David", "Frank", "Chris", would it be better to do:
[Code]...
Also, what is the difference if you put the () with the variable name or with the type? I see sometimes
[Code]...
ok so i have a .txt file that is a log of events. they pretty much follow this format:
[Code]...
The problem I'm having is that it seems like strings have to be initialized differently than other types and I don't know what I'm doing wrong.
Public Class Class1
Private intNum() As Integer
Private dateString() As String
[code].....
What's the easiest way to join an array of strings?
View 3 RepliesWhy does the following not work below? I get an error on the first bracket "{" saying "Expression Expected"[code]...
View 2 RepliesIs there a way to sort an array in VB that would put J10 and J11 after J9?
J1 (PN= 605848)
J10 (PN= 605987)
J11 (PN= 605987)
[code].....
This is what I get after I run myArray.sort()
Each array string represents a text file in a folder. I want the array to be sorted based on what the text file contains. How would I do that?
View 1 RepliesWhat is the best way to clear an array of strings?
View 4 RepliesI am creating a Simple Publisher Application in which I need to insert texts in different textbox from an array of strings .I have coded it like this .
Dim texts(40) As String 'Array of strings to be inserted
shpTextBox = appPub.ActiveDocument.Pages(pageIndex).Shapes.AddTextbox _
(Orientation:=PbTextOrientation.pbTextOrientationHorizontal, _[code]......
Now It only populates first text box with the first string in the array (For 0th index) and rest textboxes contains empty strings ,though texts array has values.
I'd like to be able to do something like this:
Dim newdata(,) As String = New String(,) { _
{"foo", "bar"}, _
{"fum", "baz"} _
[code]....
If I change the outer loop to:
For Each str() As String In newdata
It builds ok but I don't get what I want. The outer loop process the elements of newdata as a 1d array and the inner loop sees each character of the strings from the outer loop.So...is there a way to use the for each structure and process a 2d string array? If so, what should I change? If not, what is the best alternative?
add all of the items of an enumeration into a an array of strings....
1
Enum Test
apple = 0
plum = 1
[code]....
If possible I'd like to dynamically at the start of my code be able to add apple, plum, carrot and scotch to the contents of an array (really a combobox) and if I have to had another item to the Enum that it automatically be added to the array.I seem to keep having to add vendor names (replacing produce/liquor) and I need the items to show up in a large project in many places and it's a pain to have to add the item to each every time.
i have an array of 30 strings , the names of the commands send to the serial port, the serial port adresses 16 devices. each device has its own set of commands.
of course i could make subarrays for each device, but for the saving of memory it would be better to use a integer index to name the commands, so like command 0 to 30.
dim command(29) as array of strings.
dim device(7) as array of devices.