Hi
i am trying to write a program in vb.net that will display text sequentially one word at a time in the centre of the screen. I have managed to split file into words but i am just stuck here lacking knowledge how to program the rest.
I would appreciate if someone has any ideas about it??
Please help me.

Thanks

You need to know GDI+ or some other technique

Other Technique:

> Draw a Label in Form,
> Set Autosize Property to False
> Set Dock Property To Fill
> Set TextAlign Property to Middle Center

Now you can display the word in the Label which will be displayed in center.

Thanks mate..i really appreciate your response and i will try that.

Hi selvaganapathy
i have been trying this code. It only displays the last word in the file, but my idea is to display all words in the file one by one at the same place on the screen. i am trying to write a program which is similar to one@ this address
http://wordflashreader.sourceforge.net/
what is your idea about it?
Thanks

Dim filestream As StreamReader = New StreamReader("C:\sample.txt")
Dim readcontents As String
readcontents = filestream.ReadToEnd()
Dim textdelimiter As String
textdelimiter = " "
Dim splitout = Split(readcontents, textdelimiter)

Dim i As Integer
For i = 0 To UBound(splitout)
Label1.Text = splitout(i)
Next
filestream.Close()

What is happening is you don't have a delay in your loop. All the words are going there but is happening so fast you don't see it. After the "Label1.Text = splitout(i)" put in a Sleep(1000).

Hi
Thanks for replying Wayne
I have tried adding a timer in the loop with interval set to 1000ms in the properties
but it still shows the last word only. what else can i use to add delay.
please help
Thanks

For i = 0 To UBound(splitout)

Label1.Text = splitout(i)
Timer1.Enabled = True


Next

Hi harry,

> Use Form level array(say A) to hold all the words in a file
> Use form level integer to hold the current index(say ci)
> When Form loads read the words in the file and store it in the array (A), initialize Current index to 0, then Enable the timer

In timer
>Display the array content of current index (A(ci) )
>increament /Decrement the current index by 1 (To display next/previous word)
>Check the boundary Condition

I given the pseudo code, you develop the code using this.

Hi selvaganapathy
Thanks for replying. i have managed to write the correct loop. but the porblem is it works fine in the console window(displays all words in a file sequentially) but if try to display words in a label then although there are no errors and it starts running but nothing comes up in the label and it just freezes for the duration of the text file being read.what do u think?
Please let me know
Thanks

Hi selvaganapathy
this is my code for the loop which works well in console window but not in a label or a text box.
Please help.
Thanks

'array for storing words
Dim splitout() = Split(readcontents, textdelimiter)
Dim i As Integer

While Not i = UBound(splitout) - 1

Do
i = i

TextBox1.Text = splitout(i)
System.Threading.Thread.Sleep(1000)
i = i + 1

Loop
End While

You have too many loops, you only need one. You also have to refresh your textbox. Try this:

Public Class Form1
    Dim readcontents As String = "The quick brown fox jumps over the lazy dog"
    Dim textdelimiter As String = " "

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'array for storing words
        Dim splitout As String() = Split(readcontents, textdelimiter)

        For i As Integer = 0 To UBound(splitout)
            TextBox1.Text = splitout(i)
            TextBox1.Refresh()
            System.Threading.Thread.Sleep(1000)
        Next

    End Sub
End Class

wow..it has worked..i am very happy and many thanks for helping me with this program.
Thanks wayne and selvaganapathy
Take care

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.