Question How to make "story"

Olsn

New member
Joined
Jan 5, 2009
Messages
3
Programming Experience
Beginner
Hey there. I just started scripting for a couple days ago. I i want to make a likely "story" exsample:

I have a Button and a textbox. And every time i press the "tell" button a new word comes up, so i can make a "story" but i can't get more than 1 word :(

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim word1 As String
        Dim word2 As String
        word1 = ("Hi")
        word2 = ("There")

        TextBox1.Text = word1


    End Sub

Can you help me? :(
 
Hello.

First, it's programming, not scripting.

And second, you'd need a indicator to know which word is shown...f.e. using a list or something.

VB.NET:
Dim word1 as String = "Hi"
Dim word2 as String = "There"

If TextBox1.Text = word1 then
      TextBox1.Text = word2
Else
      TextBox2.Text = word1
End If

VB.NET:
Dim words as New List(of String)
words.Add("Hi")
words.Add("There")

TextBox1.Text = words(words.IndexOf(TextBox1.Text) + 1)

Bobby
 
Thanks for your answer. I tried the last method, and if i press after the word "there" has showed, it fails.

could it be made something like this:

if text1.text =! NULL {
+1
}

if you understand me :cool:
 
Oh yeah, you're right...it's more like:
VB.NET:
'IndexOf returns -1 if it wasn't found in the collection, and check if the
'word is the last one...means if it is within a useable range
If words.IndexOf(TextBox1.Text) >= 0 And words.IndexOf(TextBoy1.Text) < words.Count -1 Then TextBox1.Text = words(words.IndexOf(TextBox1.Text) + 1)

Bobby
 
VB.NET:
If words.IndexOf(TextBox1.Text) >= 0 And words.IndexOf[B](TextBoy1.Text)[/B] < words.Count -1 Then TextBox1.Text = words(words.IndexOf(TextBox1.Text) + 1)
Thats not working for me, nothings happens. And i belive that the the bolded text should be textbox1.text, right? :)
 
kk im bored at work so il help ya ;)
have a label, forecolor it same as your background so its invisible ;)
when a user clicks your "tell" button, add +1 to a variable
use a "select case" statement to document your story.

Heres the code im talkin bout, if u dont understand, plz reply and il try 2 explain better.

Dim storynumber as Long = 0

then, in button on click method:

storynumber +1
select case storynumber
case 1
txtStory.text = "First line of story"
case 2
txtStory.text = "Second line of story"
case 3
txtStory.text = "3rd line..."
End Select
 
You can use the & concatenation operator to add more text to existing text:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim story(3) As String
story(0) = "Tell"
story(1) = "me"
story(2) = "the"
story(3) = "answer."
For x As Integer = 0 To 3
TextBox1.Text &= story(x) & " "
Next
End Sub
 
Back
Top