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. problem with assignment

problem with assignment

Scheduled Pinned Locked Moved Visual Basic
databasegraphicshelp
5 Posts 4 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.
  • B Offline
    B Offline
    blackstar1461
    wrote on last edited by
    #1

    The value of w doesnt increase or decrease once it reaches the value 2 .. can someone please tell me why.. Thanks in advance Public Class Form1 Dim g As Graphics Dim db As Boolean Dim x As Integer = 100 Dim y As Integer = 100 Dim w As Integer = 150 Dim h As Integer = 150 Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel Console.WriteLine(e.Delta.ToString) If (e.Delta > 0) Then Console.WriteLine("in zoomin") w = w * (e.Delta / 100) Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString) Console.WriteLine("w" & w) h = h * (e.Delta / 100) End If If (e.Delta < 0) Then Console.WriteLine("zoomout") w = w / ((e.Delta * -1) / 100) h = h / ((e.Delta * -1 / 100)) End If Console.WriteLine("w" & w) Me.Refresh() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawRectangle(Pens.Black, x, y, w, h) End Sub End Class

    C D 2 Replies Last reply
    0
    • B blackstar1461

      The value of w doesnt increase or decrease once it reaches the value 2 .. can someone please tell me why.. Thanks in advance Public Class Form1 Dim g As Graphics Dim db As Boolean Dim x As Integer = 100 Dim y As Integer = 100 Dim w As Integer = 150 Dim h As Integer = 150 Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel Console.WriteLine(e.Delta.ToString) If (e.Delta > 0) Then Console.WriteLine("in zoomin") w = w * (e.Delta / 100) Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString) Console.WriteLine("w" & w) h = h * (e.Delta / 100) End If If (e.Delta < 0) Then Console.WriteLine("zoomout") w = w / ((e.Delta * -1) / 100) h = h / ((e.Delta * -1 / 100)) End If Console.WriteLine("w" & w) Me.Refresh() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawRectangle(Pens.Black, x, y, w, h) End Sub End Class

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I suspect the answer is that even if VB doesn't round e.Delta/100 to an int, once it rounds the end result to an int, it's going to not be big enough to get past 2 in either direction. Do e.Delta / 100.0 to make it work with a float, and consider what you do when the end result moves the value by less than .5, which means it will round back to what it was. Perhaps you need to store w as a float, and make it an int only when you're using it to draw with.

      Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

      1 Reply Last reply
      0
      • B blackstar1461

        The value of w doesnt increase or decrease once it reaches the value 2 .. can someone please tell me why.. Thanks in advance Public Class Form1 Dim g As Graphics Dim db As Boolean Dim x As Integer = 100 Dim y As Integer = 100 Dim w As Integer = 150 Dim h As Integer = 150 Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel Console.WriteLine(e.Delta.ToString) If (e.Delta > 0) Then Console.WriteLine("in zoomin") w = w * (e.Delta / 100) Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString) Console.WriteLine("w" & w) h = h * (e.Delta / 100) End If If (e.Delta < 0) Then Console.WriteLine("zoomout") w = w / ((e.Delta * -1) / 100) h = h / ((e.Delta * -1 / 100)) End If Console.WriteLine("w" & w) Me.Refresh() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawRectangle(Pens.Black, x, y, w, h) End Sub End Class

        D Offline
        D Offline
        Dinesh Vitharana
        wrote on last edited by
        #3

        Public Class Form1 Dim g As Graphics Dim db As Boolean Dim x As Integer = 100 Dim y As Integer = 100 Dim w As Integer = 150 Dim h As Integer = 150 Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel Console.WriteLine(e.Delta.ToString) If (e.Delta > 0) Then Console.WriteLine("in zoomin") w = IIf((w * (e.Delta / 100)) < 3, 3, (w * (e.Delta / 100))) 'w = w * (e.Delta / 100) Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString) Console.WriteLine("w" & w) h = IIf((h * (e.Delta / 100)) < 3, 3, (h * (e.Delta / 100))) 'h = h * (e.Delta / 100) End If If (e.Delta < 0) Then Console.WriteLine("zoomout") w = w / ((e.Delta * -1) / 100) h = h / ((e.Delta * -1 / 100)) End If Console.WriteLine("w" & w) Me.Refresh() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawRectangle(Pens.Black, x, y, w, h) End Sub End Class dinvit83

        C 1 Reply Last reply
        0
        • D Dinesh Vitharana

          Public Class Form1 Dim g As Graphics Dim db As Boolean Dim x As Integer = 100 Dim y As Integer = 100 Dim w As Integer = 150 Dim h As Integer = 150 Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel Console.WriteLine(e.Delta.ToString) If (e.Delta > 0) Then Console.WriteLine("in zoomin") w = IIf((w * (e.Delta / 100)) < 3, 3, (w * (e.Delta / 100))) 'w = w * (e.Delta / 100) Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString) Console.WriteLine("w" & w) h = IIf((h * (e.Delta / 100)) < 3, 3, (h * (e.Delta / 100))) 'h = h * (e.Delta / 100) End If If (e.Delta < 0) Then Console.WriteLine("zoomout") w = w / ((e.Delta * -1) / 100) h = h / ((e.Delta * -1 / 100)) End If Console.WriteLine("w" & w) Me.Refresh() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawRectangle(Pens.Black, x, y, w, h) End Sub End Class dinvit83

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Not very efficient, but it works. I prefer to lead people to water, rather than throw water at them.

          Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

          _ 1 Reply Last reply
          0
          • C Christian Graus

            Not very efficient, but it works. I prefer to lead people to water, rather than throw water at them.

            Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

            _ Offline
            _ Offline
            _Damian S_
            wrote on last edited by
            #5

            Christian Graus wrote:

            lead people to water, rather than throw water at them

            Remind me never to spontaneously combust around you!!

            Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010

            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