.

trying to make my 3rd program :D

<<

Sentientphil

Newbie
Newbie

Posts: 2

Joined: Fri Jan 28, 2011 3:49 am

Post Tue May 10, 2011 4:05 pm

trying to make my 3rd program :D

First off, thanks for a great site! i never even knew "hacking" could be ethical until i found this site!  which in turn has made me want to learn some programming :D ok, so far im learning how to drag and drop :s.. but, you have to start somewhere :D

some background stuff... i have actually written some code in VB(added 4 statements lol) to make a program that outputs whatever text you input into a text box and it will repeat it every second(or whatever) until you click stop...

I am trying this in Visual Basic code using Visual Studio 2010

the UI comprises of a start button, stop button, and a text box..
added a timer,
added SendKeys.Send(TextBox1.Text) and
SendKeys.Send("{Enter}") to the timer... and
added Timer.Start() and Timer.Stop() to the start and stop button... that was simple with a tutorial i followed..

so now i can do that without even looking at a tutorial.... natural progression has made me try adding a load of TextBox's so i could enter say "My Name" in box one, then "FirstLineOfMyAddress" in box two then "SecondLineOfMyAddress" in box 3 etc etc etc..  so it would out putlike this in notepad/word/etc:

My Name
FirstLineOfMyAddress
SecondLineOfMyAddress
etc etc etc etc

many many thanks for your help... i will add the code i have so far below so you have an idea what im doing...

-----------------
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send(TextBox1.Text)
        SendKeys.Send("{Enter}")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub
End Class
----------------

it would be nice to have like 10 TextBox's so that they output with a slight delay.. i.e.

output TextBox1.Text
Pause for 250
output TextBox2.Text
Pause for 250
etc etc

because i noticed that when i "tried" setting up multiple TextBox's each with a timer (i was experimenting :D) that it was just mayhem lol! no order at all!

P.S I am VERY new to code, (a day old lol) so be gentle.. dont bite my head off lol.. getting annoyed at the internet for those damn children that should be doing homework not trolling everyone...
<<

nonexistententity

Newbie
Newbie

Posts: 15

Joined: Tue Jul 19, 2011 11:32 am

Post Wed Jul 20, 2011 12:15 pm

Re: trying to make my 3rd program :D

Can you be more specific as to what role the timer is playing in all of this?

You could simply add one more timer and a counter to go along with it. Say, for example, your new timer goes off once every 2 seconds: (I'm more C# based so i'll make this a little more pseudo code but note where i've made changes..

-----------------
Public Class Form1

    Dim m_counter As Integer [CHANGE #1]

    [IN THE FORM_LOAD EVENT, SET THE COUNTER = 0]

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send(TextBox1.Text)
        SendKeys.Send("{Enter}")
    End Sub

    [HERE IS MY SECOND FUNCTION/CHANGE]
    Private Sub Timer2_Tick(ByVal send as System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

    if counter = 0 then
      [Populate Name Text Box]
    else if counter = 1 then
      [Populate Address Box]
    else if counter = 2 then
      .....

    counter = counter + 1

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub
End Class
----------------

Using the function and counter I just put in, you can have that timer go off as often as you want and each time the counter increases by 1 changing which box gets filled in. It's a pretty UNfancy solution but it's quick and dirty and gets you thinking about patterns and counters and so on.

Hope that helps...

-N33
 

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

.
Powered by phpBB® Forum Software © phpBB Group.
Designed by ST Software