Author Topic: Swapping screens every 45 seconds  (Read 1185 times)

jsu0234m

  • Newbie
  • *
  • Posts: 16
    • View Profile
Swapping screens every 45 seconds
« on: August 10, 2018, 06:11:45 AM »
I'm working on a project that has two screens and i want them to swap back and forth between each other after a certain amount of time. I have the two screens working and can swap back and forth as needed with form change buttons but i would like to add a button to enable the screens to swap back and forth on there own after a certain time has passed.

Process:
Main screen opens when project opens, press a button to enable screen swapping, wait 45 seconds and then swap to the 2nd screen, wait 45 seconds and swap back to the first screen. Repeat until screen swapping is turned off.

I have a timer on the screen and set to 45 seconds but i can't figure out how to actually call the screen change when the timer is done.

Any help would be appreciated, i've googled my heart out and i don't think i know enough about visual studio to search for the right help because i have found about everything else besides calling a form change button.

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Swapping screens every 45 seconds
« Reply #1 on: August 10, 2018, 04:11:34 PM »
If you mean forms, then add timers & buttons to each form, and add something like below to each click & tick event to both forms:
 Me.Hide()
        Timer1.Stop()
        Form2.Timer2.Start()
        Form2.Show()

above example is for form1. swap the number for form2
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Swapping screens every 45 seconds
« Reply #2 on: August 13, 2018, 07:56:47 PM »
You can also do it with one form, one timer, two panels, panel size will be close to the form size. on each panel will  have one button:

Form_Load
Code: [Select]
For Each ctrl As Control In Controls
            If ctrl.GetType Is GetType(Panel) Then
                Panel2.Visible = False
                Panel1.Visible = True
            End If

        Next

Button1_Click:
Code: [Select]
        Timer1.Stop()
        Timer1.Start()
        Panel2.Visible = True
        Panel1.Visible = False
Button2_Click:
Code: [Select]
        Timer1.Stop()
        Timer1.Start()
        Panel2.Visible = False
        Panel1.Visible = True

Timer Tick:
 Private formflag As Boolean = False
Code: [Select]
If formflag Then
            Panel2.Visible = False
            Panel1.Visible = True
        Else
            Panel2.Visible = True
            Panel1.Visible = False
        End If
        formflag = Not formflag
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

jsu0234m

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Swapping screens every 45 seconds
« Reply #3 on: October 11, 2018, 10:38:33 AM »
Thanks for your help. I got caught up in another project and am just now getting back to this. I'll try these and see what i can figure out.