I am trying to make all possible combination of a string except the regular ones,
For exemple if i put on a TextBox ABCDEFGH i don't need AAAAAAAAAA or BBBBBBBB or ABABABAB or ABCDABCD and so on...
I need all possible combination but only randomly ones not symetric ones, for exemple: BCGHDAAC or ACEEFAGH... etc
Is there a way to do that? Because i really don't know how to do it
I tried this one but it's not giving me all results
Dim i As Integer = 0
Do Until i = TextBox1.Text.Length
RichTextBox1.Text = RichTextBox1.Text & TextBox1.Text.Substring(i, +1)
i = i + 1
Loop
i = TextBox1.Text.Length
Do Until i = 0
RichTextBox1.Text = RichTextBox1.Text & TextBox1.Text.Substring(i, +1)
i = i - 1
Loop
Thank you for help
Related
I would need a little help.
Textbox1.Text contains 1,2,3,4,5,6,17.
Data in Textbox2:
Lines 0 = 1,2,3,4,5,7,18
Lines 1 = 21,2,3,4,5,7,19
Lines 2 = 13,11,3,4,5,7,19
Lines 3 = 1,2,3,4,5,6,17
Lines 4 = 1,2,3,4,5,6,21
How can I do?
For Each lines In Textbox2.Lines
Next
Expected Output: Textbox3.Text contains 3 (Because the combination from Textbox1 is found on the line 3 in the data).
Don't use for each.
You should iterate over your lines with an index and return the index.
Code exmaple:
For index As Integer = 0 To TextboxX.Lines.Length Step 1
' Here you can use your logic to check if the current line (by the index) is correct using TextboxX.Lines(index).
' Something like TextboxX.Lines(index) = Textbox1.text
If TextboxX.Lines(index) = Textbox1.Text Then
Textbox3.Text = index
Exit For
End If
Next
Bonus
This logic is already implemented in the framework, and it looks better like this:
Textbox3.Text = Array.IndexOf(TextboxX.Lines, Textbox1.Text)
Note - if the value was not found Array.IndexOf will return -1
okay so i have two textboxes for user input, and i need help storing these into a single two dimensional array.
for 49 columns and two rows (states, capitals)
i already declared the array to:
Dim states(49,1) as string
states(0,0)= textbox1.text
states(0,1) = textbox2.text
im not sure what else to do because i have
am i storing this right? im not sure what more to do to store the rest of input into the array.
any help would be appreciated. thank you!
Declare module/class scope variables:
Dim states(49,1) as string
Dim nextInd as Integer = 0
Then in your button click handler:
If nextInd <= 49 Then ' Make sure you are not trying to fill values past the dimensions of the array
states(nextInd, 0) = textbox1.text
states(nextInd, 1) = textbox2.text
nextInd += 1 ' To increment the next index to use by 1
textbox1.text = ""
textbox2.text = ""
End If
And then to display the contents of the array, you need a loop:
' Use a string builder so you can modify the same string object to show it all together in the message box
Dim contents As New StringBuilder("")
For st = 0 To 49
contents.Append(states(st, 0) & ": " & states(st, 1) & Environment.NewLine)
' Or however you want To format it
Next
MessageBox.Show(Me, contents) ' MsgBox is old - use MessageBox instead
I built my application and my application has a search textbox that searching for a specific text in string and the problem is I have to search the text in uppercase and small case, let's say the string = "Knife doppler" then if I want to find it I need to write in the search area in uppercase if I want to find any results, like this: "Knife" and if I search for "knife" I will get no results, how can I do that uppercase and small caps worth the same? I want to get a result if I search in uppercase or in small caps...
If TextBox2.Text = "" Then
TextBox1.Text = TextBox3.Text
Else
TextBox1.Text = ""
Dim lineCount As Integer = TextBox3.Lines.Count - 1
Dim counter As Integer = 0
For index As Integer = 0 To lineCount
If TextBox3.Lines(index).IndexOf(TextBox2.Text) >= 0 Then
counter += 1
TextBox1.AppendText(TextBox3.Lines(index).ToString() + vbNewLine)
End If
Next
End If
If you look at the documentation of IndexOf you will find an overload that takes a StringComparison enum value that allows you to ignore the difference in text case.
If TextBox3.Lines(index).
IndexOf(TextBox2.Text,
StringComparison.CurrentCultureIgnoreCase) >= 0 Then
.....
Basically, how do I write a new line in a text box, keeping the existing information as well.
If I have for loop,
For i As Integer = 1 To 10
Dim result = i
i = i + 1
textbox1.text = result
Next
This will display '10' in the textbox. I want it to be like:
1
2
3
4
...
First, your TextBox must allow multiple lines. This is a property of the textbox control that you can set from the designer or from the code. You may want to ensure that a scroll bar is there to scroll in case the height is not large enough.
If you want to set the properties from code, use this code in the Load event of the form.
' Set the Multiline property to true.
textBox1.Multiline = True
' Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical
' Change the height of the textbox so that it could accomodate the lines
TextBox1.Height = 120
Now, your approach had a major problem in this line:
textbox1.text = result
The way you coded it, every new value of i, would overwrite the old value. What you want to do is to first construct a string, then send the entire string to the TextBox control. This is not required had you been using Console.WriteLine method.
Method 1
Dim s as string
s=""
For i As Integer = 1 To 10
s = s & Environment.Newline & i.ToString() 'we use Environment.NewLine to force new line
Next i
textbox1.text = s
Method 2
.NET offers a class to handle strings better than the way we did before. It won't matter in your case but it is the efficient way to handle concatenation when volume is large and/or performance matters
Dim s as new System.Text.StringBuilder() 'Initialize stringbuilder instance
For i As Integer = 1 To 10
s.AppendLine (i.ToString()) 'We use stringbuilder to concat. and inser line feed
Next i
textbox1.text = s.ToString()
Note: If you want double spacing then you need to add a linefeed (using & ) to both of the above methods.
Something like this should work:
For i As Integer = 1 To 10
if i = 1 then
textbox1.text = i
else
textbox1.text &= vbcrlf & i
end if
Next
For i = 1 To 10
textbox1.AppendText(vbNewLine & i)
Next
Ok, so im trying to make this program and i need this:
"Melternet Hello Melternet#gmail.com 5/7/2013" to be in different textbox's like this
"Textbox1 = Melternet"
"Textbox2 = Hello"
"Textbox3 = Melternet#gmail.com"
"Textbox4 = 5/7/2013"
So pretty much every space is a cut off line to add that text to a textbox and then it does the rest like the first one
How would i do something like that, thanks in advance.
Please Answer Back If Anyone Can Figure This Out Or Help Me, NEED THIS QUICK...
BTW: i'm using Visual Basic 2008.
Without more info...something like:
Dim data As String = "Melternet Hello Melternet#gmail.com 5/7/2013"
Dim values() As String = data.Split(" ")
If values.Length >= 4 Then
TextBox1.Text = values(0)
TextBox2.Text = values(1)
TextBox3.Text = values(2)
TextBox4.Text = values(3)
End If
It looks like you are simply splitting the entire input text string: "Melternet Hello Melternet#gmail.com 5/7/2013" wherever a space occurs, yes(?)
If your string has a variable number of words, then fill up textboxes programmatically, like, e.g.:
Dim mystr as String
mystr = "hello world I want to paste this to multiple textboxes"
Dim Buff() as String
Buff = Split(mystr," ")
For i As Integer = 0 to UBound(Buff)
Dim tb As New TextBox
str = Buff(i)
tb.Name = str
tb.Text = str
tb.Left = 50
tb.Top = 50 + 25 * i
tb.Width = 50
tb.TextAlign = HorizontalAlignment.Right
Me.Controls.Add(tb)
Next
In the above fashion, no matter what the value of mystr, or how many words are in the string (mystr), you can write them all to new textboxes that are created/placed dynamically on Form1, i.e. "Me".