none
value of type 'system.drawing.size' cannot be converted to to integer RRS feed

  • Question

  • Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
            TrackBar1.Value = OvalShape2.Size

    End Sub

    When i type this code i got the error please help me !

    Thursday, June 27, 2019 6:47 AM

All replies

  • Hi,

    Do you want to change the size of OvalShape2 with Scroll TrackBar1.Value?

    Public Class Form1
        Dim ph As Integer
        Dim pw As Integer
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            PictureBox1.BackColor = Color.Black
            ph = PictureBox1.Size.Height
            pw = PictureBox1.Size.Width
            TrackBar1.Minimum = 1
            TrackBar1.Maximum = 4
        End Sub
        Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
            PictureBox1.Width = pw * TrackBar1.Value
            PictureBox1.Height = ph * TrackBar1.Value
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 27, 2019 7:12 AM
  • Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
            TrackBar1.Value = OvalShape2.Size

    End Sub

    When i type this code i got the error

    OvalShape2.Size is a Struct in the System.Drawing namespace that consists of
    an ordered pair of integers representing the Height and Width. The 
    TrackBar Value property is a single Int32. You can't assign a struct to an integer.

    - Wayne

    Thursday, June 27, 2019 8:15 AM