|
-
Apr 14th, 2008, 12:28 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Int keeps rounding to whole number...HELP!
I have code that for some reason or another itsnt doing what it should be doing.
Heres the code:
Code:
Dim scales As Integer = 1
.
.
.
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
formGraphics.Clear(Color.Black)
Select Case e.Delta
Case Is < 0
scales = scales / 1.5
Case Is > 0
scales = scales * 1.5
End Select
Button1.Text = scales
writer()
End Sub
As I scroll the wheel, "scales" only moves by whole numbers. Whats causing this issue?
Full code (I know it's sloppy right now):
Code:
Public Class Form1
Dim dxs As Integer
Dim dys As Integer
Dim scales As Integer = 1
Dim obj As String
Dim x As Single
Dim y As Single
Dim xx As Single
Dim yy As Single
Dim d As Single
Dim ang1 As Single
Dim ang2 As Single
Dim ang3 As Single
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
Dim deltax As Integer = 0
Dim deltay As Integer = 0
Dim flag As Boolean = False
Dim objects(1000, 5) As Integer
Dim objnum As Integer = 1
Private Sub reader()
FileOpen(1, "C:\Documents and Settings\Temp\Desktop\xxx.dxf", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
Do While Not EOF(1)
obj = LineInput(1)
If obj = "EOF" Then Exit Do
If obj = "ENTITIES" Then Exit Do
Loop
Do While objnum < 10000
obj = LineInput(1)
If obj = "EOF" Then Exit Do
Select Case obj
Case "LINE"
obj = LineInput(1)
objects(objnum, 1) = 1
Do
obj = LineInput(1)
Select Case obj
Case " 10"
objects(objnum, 2) = LineInput(1)
Case " 20"
objects(objnum, 3) = LineInput(1)
Case " 11"
objects(objnum, 4) = LineInput(1)
Case " 21"
objects(objnum, 5) = LineInput(1)
Case " 0"
Exit Do
End Select
Loop
objnum = objnum + 1
' formGraphics.DrawLine(myPen, (x * scales) + deltax, (1000 - y * scales) + deltay, (xx * scales) + deltax, (1000 - yy * scales) + deltay)
Case "CIRCLE"
obj = LineInput(1)
objects(objnum, 1) = 2
Do
obj = LineInput(1)
Select Case obj
Case " 10"
objects(objnum, 2) = LineInput(1)
Case " 20"
objects(objnum, 3) = LineInput(1)
Case " 40"
objects(objnum, 4) = LineInput(1)
Case " 0"
Exit Do
End Select
Loop
objnum = objnum + 1
' formGraphics.DrawEllipse(myPen, New Rectangle((x * scales) - (d * scales) + deltax, 1000 - (y * scales) - (d * scales) + deltay, (d * scales * 2), d * scales * 2))
Case "ARCl"
obj = LineInput(1)
Do
obj = LineInput(1)
Select Case obj
Case " 10"
x = LineInput(1)
Case " 20"
y = LineInput(1)
Case " 40"
d = LineInput(1)
Case " 50"
ang1 = LineInput(1)
Case " 51"
ang2 = LineInput(1)
Case " 0"
Exit Do
End Select
Loop
If ang1 < ang2 Then ang3 = ang1 - ang2 Else ang3 = (ang1 - ang2) - 180
formGraphics.DrawArc(myPen, (x * scales) - ((d * scales)), 1000 - (y * scales) - (d * scales), d * 2 * scales, d * 2 * scales, ang2 + 180, ang3)
MsgBox(ang1 & ":" & ang2 & ";" & ang1 & ":" & ang1 + ang3)
End Select
Loop
FileClose(1)
writer()
End Sub
Private Sub writer()
For i As Integer = 1 To objnum
Select Case objects(i, 1)
Case 1
formGraphics.DrawLine(myPen, (objects(i, 2) * scales) + deltax, (1000 - objects(i, 3) * scales) + deltay, (objects(i, 4) * scales) + deltax, (1000 - objects(i, 5) * scales) + deltay)
Case 2
formGraphics.DrawEllipse(myPen, New Rectangle((objects(i, 2) * scales) - (objects(i, 4) * scales) + deltax, 1000 - (objects(i, 3) * scales) - (objects(i, 4) * scales) + deltay, (objects(i, 4) * scales * 2), objects(i, 4) * scales * 2))
End Select
Next
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.Button = Windows.Forms.MouseButtons.Middle Then
deltax = deltax + (e.X - dxs)
deltay = deltay + (e.Y - dys)
formGraphics.Clear(Color.Black)
writer()
dxs = e.X
dys = e.Y
End If
End Sub
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
formGraphics.Clear(Color.Black)
Select Case e.Delta
Case Is < 0
scales = scales / 1.5
Case Is > 0
scales = scales * 1.5
End Select
Button1.Text = scales
writer()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
formGraphics.Clear(Color.Black)
reader()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
formGraphics = Me.CreateGraphics()
formGraphics.Clear(Color.Black)
writer()
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
flag = False
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If flag = False Then
flag = True
dxs = e.X
dys = e.Y
End If
'End If
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|