splitting a string [duplicate] - vb.net

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
splitting a string
i have a string which looks like this:
http://pastebin.com/m5508ff19
i need to get each of the numbers and put them in an array in this order: 0, 50, 100, 100, 200, 400, 218, 9.8, ???, 6.65, 6.31 etc...
i have the following code but for some reason it only does the first column, it only gives me 0, 50, 100, 100, 200, 400, 218, 9.8, ???
Dim list_numbers As New List(Of String)
Dim fields() As String
fields = calculationText.Split(Environment.NewLine)
For Each CurrLine As String In fields
list_numbers.Add(CurrLine.Split(Char.Parse(" "))(0))
Next
i need help to get every number in an array in the above order

Didn't you already ask this question? Did the answers provided there not help you?

You're adding a (0) at the end of the second Split() function; this will only grab the first element.
(Disclaimer - I don't know VB.Net, but this is my best guess based on my C# experience.)

Related

VB.net adding values to 2 dimensional datetime array

I defined a two dimensional array like that
Dim dates As DateTime(,) = {}
How can I put two dates into it?
Thank you.
It is possible. People can be unhelpful and unfriendly on here, forgetting that they were inexperienced programmers at one time too. Take the time to read up here: https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/arrays/how-to-initialize-an-array-variable
Dim Dates(,) As Date = {
{New Date(2000, 1, 1), New Date(2001, 1, 1)},
{New Date(2000, 1, 2), New Date(2002, 1, 1)}
}

Limesurvey get combo values of a question

When I perform an export_responses call to the API, I get the questions and values.
For combo type questions, I get the ID of the selected option, but not the description.
How can I access the descriptions of these values?
Thank you in advance!
The parameter sResponseType in the API allows you to choose if you want to get the Answer Codes or the Answer Texts.
Please see https://api.limesurvey.org/classes/remotecontrol_handle.html#method_export_responses
Export token response in a survey.
export_responses_by_token(string
$sSessionKey, integer $iSurveyID, string $sDocumentType, string
$sToken, string $sLanguageCode = null, string $sCompletionStatus =
'all', string $sHeadingType = 'code', string $sResponseType = 'short',
array $aFields = null) : array|string
...
...
sResponseType (optional)'short' or 'long' Optional defaults to 'short'

how can i write a method to check characters whether it matches the input argument? [duplicate]

This question already has answers here:
In Java, how do I check if a string contains a substring (ignoring case)? [duplicate]
(6 answers)
Closed 6 years ago.
I want to write a boolean function call isDistrict (String districtCheck) {}
and i need to use this method for checking district is the same as disrictCheck, if yes it will return turn and the other will return flase.but i hv no ideal to do this.
public boolean isDistrict (String districtCheck) {
// TODO: Missing logic. Help
}
For example if I would have this String, where I would like to check for Kwun Tong:
address:Room A,32/F,456 XXX,Kwun Tong,Kowloon
districtCheck:Kwun Tong true
When I would check for Hung Hom, I would get:
districtCheck:Hung Hom false
String address = "Room A,32/F,456 XXX,Kwun Tong,Kowloon"
...
public boolean isDistrict (String districtCheck){
return address.contains(districtCheck)
}

Split text file into several parts by character

I apologise in advance if there is already an answer to this problem; if so please just link it (I have looked, btw! I just didn't find anything relating to my specific example) :)
I have a text (.txt) file which contains data in the form 1.10.100.0.200 where 1, 10, 100, 0 and 200 are numbers storing the map terrain layout of a game. This file has multiple lines of 1.10.100.0.200 where each line represents an item of terrain in the map.
Here is what I would like to know:
How do I find out how many lines there are, so I know how many items of terrain to create when I read the map file?
What is the method I should use to get each of 1, 10, 100, 0 and 200:
E.g. when I am translating the file into a map terrain at runtime I might use the terrainitem1.Location = New Point(x, y) or terrainitem1.Size = New Size(p, q) commands, where x, y, p and q are integers or doubles relating to the terrain's location or size. Where would I then find x, y etc. out of 1, 10, 100, 0 and 200, if say x is equal to 1, y to 10 and so on?
I am sorry if this isn't clear, please just ask me and I'll try to explain.
N.B. I am using VB.NET WinForms
There is no way to know how many lines a file has without opening the file and reading its contents.
You didn't indicate how far you've got on this. Do you know how to open a file?
Here's some basic code to do what you want. (Sorry, this is C# but the idea is the same in VB.)
string line;
using (TextReader reader = File.OpenText(#"C:\filename.txt"))
{
// Read each line from the file (until null returned)
while ((line = myTextReader.ReadLine()) != null)
{
// Get each number in line (as string)
string[] values = line.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
// Convert each number to integer
id = int.Parse(values[0]);
height = int.Parse(values[1]);
width = int.Parse(values[2]);
x = int.Parse(values[3]);
y = int.Parse(values[4]);
}
}

IsDayLightSavingTime changed?

Before, this code would return True, now it returns False. Have any of you hear of an update on this function?
d2 = New DateTime(2010, 11, 7, 1, 0, 0)
Console.WriteLine("D2: " & System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(d2))
We parse files and put the data into a database, if I parse the exact same file with the same code (it was never changed) I get different results.
Update
This is EST/EDT