Spin “Spinning Syntax” Text Using VB.Net

A simple text spinner program using VB.Net, used  to spin text written in the familiar spinning syntax e.g. {sample|example|exhibit}

This program doesn’t spin nested syntax.

You’ll need:

2 Text Boxes (TextBox1, TextBox2)

1 Button (Button1)

Code:



Public Class Form1
    Dim str As String
    Dim strAll
    Dim strStart = 1
    Dim strEnd = 1
    Dim words As Array
    Dim word
    Dim intRWord As Integer
    Dim spin = 1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox2.Text = TextBox1.Text

        Do While spin = 1
            If InStr(strEnd, TextBox2.Text, "{", CompareMethod.Text) > 0 Then
                strStart = InStr(strEnd, TextBox2.Text, "{", CompareMethod.Text)
                strEnd = InStr(strStart, TextBox2.Text, "}", CompareMethod.Text)
                strAll = Mid(TextBox2.Text, strStart, strEnd - strStart + 1)
                str = Mid(TextBox2.Text, strStart + 1, strEnd - strStart - 1)
                words = Split(str, "|", -1, CompareMethod.Text)
                intRWord = words.GetUpperBound(0) * Rnd()
                word = words.GetValue(intRWord)

                TextBox2.Text = Replace(TextBox2.Text, strAll, word, 1, 1, CompareMethod.Text)
                strStart = 1
                strEnd = 1
            Else
                spin = 0

            End If
        Loop
        spin = 1
    End Sub
End Class

Text Spinner Using VB.Net

2 thoughts on “Spin “Spinning Syntax” Text Using VB.Net”

  1. Hi Thaer, i need a spinning text for Spanish, how i could create it using Visual Studio Professional 2008?

    Coul you help me in that?

    Thanks! Regards,

    Robert

  2. Hey this is a great script.
    Now i would like that it would keep spinning for a given number of repetitions and each time what appears on textbox2 to be pasted on a excel sheet. Do you have any idea how can i do this?

Leave a Reply

Your email address will not be published. Required fields are marked *