Hej Er den en der kan være behjælpelig med et par linjer code, til når jeg trykker på en knap bliver der tegnet en linje i en pictureBox? Jeg kender code til vb 6,0 men sidder lige nu med vb2008 Express hvor det er anderledes
Imports System Imports System.Drawing Imports System.Windows.Forms
Public Class MainForm Inherits Form Private Const MAX_SPEED As Integer = 200 Private speed As Integer Private speedshow As PictureBox Private up As Button Private down As Button Public Sub New() speed = 0 speedshow = New PictureBox() up = New Button() down = New Button() SuspendLayout() speedshow.Location = New Point(50, 50) speedshow.Size = New Size(300, 300) speedshow.BorderStyle = BorderStyle.FixedSingle AddHandler speedshow.Paint, AddressOf ShowPaint up.Location = New Point(50, 400) up.Size = New Size(150, 50) up.Text = "Speed up" AddHandler up.Click, AddressOf UpClick down.Location = New Point(200, 400) down.Size = New Size(150, 50) down.Text = "Speed down" AddHandler down.Click, AddressOf DownClick ClientSize = New Size(400, 500) Controls.Add(speedshow) Controls.Add(up) Controls.Add(down) Text = "Speedometer" ResumeLayout(False) End Sub Private Sub UpClick(sender As Object, e As EventArgs) speed = Math.Min(MAX_SPEED, speed + 10) speedshow.Invalidate() End Sub Private Sub DownClick(sender As Object, e As EventArgs) speed = Math.Max(0, speed - 10) speedshow.Invalidate() End Sub Private Sub ShowPaint(sender As Object, e As PaintEventArgs) e.Graphics.FillPie(New SolidBrush(Color.Gray), 25, 100, 250, 250, 180, 180) e.Graphics.DrawLine(New Pen(Color.Red, 5), 150, 225, CSng(150 + 125 * Math.Cos(speed * Math.PI / MAX_SPEED)), CSng(225 - 125 * Math.Sin(speed * Math.PI / MAX_SPEED))) End Sub <STAThread> _ Public Shared Sub Main(args As String()) Application.Run(New MainForm()) End Sub End Class
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.