|
-
Jun 28th, 2009, 10:08 AM
#1
Thread Starter
New Member
Few Questions...
Hey guys, i want to ask you few questions...
1.In my program I have 2 textboxes.In first textbox user need to put some number.Let's say he put number 10, then in other textbox program need to write numbers from 1 - 10, like this:
Code:
1,2,3,4,5,6,7,8,9,10
If he put 20 in first textbox, in second textbox it should be:
Code:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
2.I need to do this...
Import text file to listbox.
Export items in listbox as text file.
-
Jun 28th, 2009, 10:23 AM
#2
Re: Few Questions...
I don't see one question let alone a few.
You've told us what you want to do, what are you struggling with?
-
Jun 28th, 2009, 10:26 AM
#3
Re: Few Questions...
You can use a for loop to create the output you are looking for. Take a look at an example here:
http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx
The my.computer.filesystem can help you read and write files:
http://msdn.microsoft.com/en-us/library/0b485hf7.aspx
-
Jun 28th, 2009, 10:32 AM
#4
Re: Few Questions...
Will the user ever edit that sequence of numbers 1,2,3...etc? If not, the second textbox should actually be a label.
My usual boring signature: Nothing
 
-
Jun 28th, 2009, 10:41 AM
#5
Thread Starter
New Member
Re: Few Questions...
@Negative0
That doesn't work because between every number i need comma.
-
Jun 28th, 2009, 12:26 PM
#6
Re: Few Questions...
to output a sequence of numbers:
vb Code:
textbox2.text = "1"
for x as integer = 2 to cint(textbox1.text)
textbox2.text &= "," & x.tostring
next
to load a listbox from a txt file:
vb Code:
listbox1.items.addrange(io.file.readalllines(filename))
to save a listbox contents to a txt file:
vb Code:
Dim items(listbox1.items.count - 1) As String
ListBox1.Items.CopyTo(items, 0)
IO.File.WriteAllLines(filename, items)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 29th, 2009, 07:16 AM
#7
Thread Starter
New Member
Re: Few Questions...
Thank you Paul it worked!
Now I have one more questions....
1.Is this possible....
I have a textbox and button.
Starting text in textbox is:
Is it possible that when i press button that it removes word "Croatia" and every word after word "Croatia" from this textbox.
Example:
This is in textbox:
Code:
I am from Croatia vdvhdfgdsfgsd
I need to remove word "Croatia" and every word after it(In this case it is "vdvhdfgdsfgsd")
-
Jun 29th, 2009, 07:26 AM
#8
Re: Few Questions...
Have a look for the IndexOf and SubString functions of a string. Look them up in MSDN or similar and you will get enough examples to help you.
-
Jun 29th, 2009, 08:23 AM
#9
Fanatic Member
Re: Few Questions...
If the user isn't going to select the word, you can do this, if not, just tweak it a little bit 
vb.net Code:
Public Sub DeleteWords() Dim sentence As String = "I'm hot Croatia and I'm bored as hell" Dim words As String() = sentence.Split(New Char() {" "c}) Dim check As Integer = 0 For i As Integer = 0 To words.Count - 1 If words(i) = "Croatia" Then check = i - 1 End If Next For c As Integer = 0 To check MsgBox(words(c) & " ") Next End Sub
Hope it helps
-
Jun 29th, 2009, 08:34 AM
#10
Re: Few Questions...
That's way more complicated than required. All you need to do is check the position of the word "Croatia" in the string using the IndexOf method, and then extract the first part using the SubString method. It can be done in one line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|