Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Sliding effect issue in VB.NET

Sliding effect issue in VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Razanust
    wrote on last edited by
    #1

    I have written a code to give a sliding effect to 5 command buttons. It runs fine with default background but when i change the opacity of the form OR put a picture in the background it behaves slower rather much slower than what it does normally. What might be the issue? Any ideas to resolve it. Here is the code.

    Public Class Form1
    Dim slidevar As Integer = -10
    Dim slidevar1 As Integer = -60
    Dim slidevar2 As Integer = -120
    Dim slidevar3 As Integer = -180
    Dim slidevar4 As Integer = -240
    Dim delayvar As Integer = -300
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Button1.Location = New Point(-1000, 10)
        Button2.Location = New Point(-1000, 80)
        Button3.Location = New Point(-1000, 120)
        Button4.Location = New Point(-1000, 160)
        Button5.Location = New Point(-1000, 200)
    End Sub
    
    Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    End Sub
    
    Private Sub Button\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
        slidevar = 0
        slidevar1 = 0
        slidevar2 = 0
        slidevar3 = 0
        slidevar4 = 0
    
        Button1.Location = New Point(-1000, 10)
        Button2.Location = New Point(-1000, 80)
        Button3.Location = New Point(-1000, 120)
        Button4.Location = New Point(-1000, 160)
        Button5.Location = New Point(-1000, 200)
        Timer1.Enabled = True
    
    
    End Sub
    
    Private Sub Timer1\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
    
        If slidevar < 65 Then
            Button1.Location = New Point(slidevar, 10)
            slidevar += 6
            If slidevar4 > 65 Then
                Timer1.Enabled = False
            End If
        End If
    
    
        For delayvar = 1 To 100
        Next
    
        If slidevar1 < 65 Then
            Button2.Location = New Point(slidevar1, 80)
            slidevar1 += 5
        End If
    
    
    
    
        For delayvar = 1 To 100
        Next
        If slidevar2 < 65 Then
            Button3.Location = New Point(slidevar2, 120)
            slidevar2 += 4
        End If
    
    
        For delayvar = 1 To 100
        Next
        If slidevar3 < 65 Then
            Button4.Location = New Point(slidevar3, 160)
            slidevar3 += 3
        End If
    
    
        For delayvar = 1 To 100
    
    S 1 Reply Last reply
    0
    • R Razanust

      I have written a code to give a sliding effect to 5 command buttons. It runs fine with default background but when i change the opacity of the form OR put a picture in the background it behaves slower rather much slower than what it does normally. What might be the issue? Any ideas to resolve it. Here is the code.

      Public Class Form1
      Dim slidevar As Integer = -10
      Dim slidevar1 As Integer = -60
      Dim slidevar2 As Integer = -120
      Dim slidevar3 As Integer = -180
      Dim slidevar4 As Integer = -240
      Dim delayvar As Integer = -300
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

          Button1.Location = New Point(-1000, 10)
          Button2.Location = New Point(-1000, 80)
          Button3.Location = New Point(-1000, 120)
          Button4.Location = New Point(-1000, 160)
          Button5.Location = New Point(-1000, 200)
      End Sub
      
      Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
      End Sub
      
      Private Sub Button\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
          slidevar = 0
          slidevar1 = 0
          slidevar2 = 0
          slidevar3 = 0
          slidevar4 = 0
      
          Button1.Location = New Point(-1000, 10)
          Button2.Location = New Point(-1000, 80)
          Button3.Location = New Point(-1000, 120)
          Button4.Location = New Point(-1000, 160)
          Button5.Location = New Point(-1000, 200)
          Timer1.Enabled = True
      
      
      End Sub
      
      Private Sub Timer1\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      
      
          If slidevar < 65 Then
              Button1.Location = New Point(slidevar, 10)
              slidevar += 6
              If slidevar4 > 65 Then
                  Timer1.Enabled = False
              End If
          End If
      
      
          For delayvar = 1 To 100
          Next
      
          If slidevar1 < 65 Then
              Button2.Location = New Point(slidevar1, 80)
              slidevar1 += 5
          End If
      
      
      
      
          For delayvar = 1 To 100
          Next
          If slidevar2 < 65 Then
              Button3.Location = New Point(slidevar2, 120)
              slidevar2 += 4
          End If
      
      
          For delayvar = 1 To 100
          Next
          If slidevar3 < 65 Then
              Button4.Location = New Point(slidevar3, 160)
              slidevar3 += 3
          End If
      
      
          For delayvar = 1 To 100
      
      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      you have already asked this question in QA[^] What have you tried since then?

      Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups