ScrollBars - NumericUpDowns : NumericUpDown « GUI « VB.Net Tutorial






imports System
imports System.Drawing
imports System.Windows.Forms

public class NumericUpDowns : inherits Form

  dim hbar as HScrollBar
  dim vbar as VScrollBar
  dim nupdwn as NumericUpDown

  public sub New()
    Size = new Size(480,580)

    hbar = new HScrollBar()
    hbar.Parent = me
    hbar.Location = new Point(0, 25)
    hbar.Size = new Size(300, 25)
    hbar.Minimum = 25
    hbar.Maximum = 400
    hbar.SmallChange = 10
    hbar.LargeChange = 100
    hbar.Value = 10
    AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged

    vbar = new VScrollBar()
    vbar.Parent = me
    vbar.Location = new Point(25, 25)
    vbar.Size = new Size(25, 300)
    vbar.Minimum = 25
    vbar.Maximum = 400
    vbar.SmallChange = 10
    vbar.LargeChange = 100
    vbar.Value = 10
    AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged

    nupdwn = new NumericUpDown()
    nupdwn.Parent = me
    nupdwn.Location = new Point(100,100)
    nupdwn.Size = new Size(60,20)
    nupdwn.Value = 1
    nupdwn.Minimum = -10
    nupdwn.Maximum = 10
    nupdwn.Increment = .25d      '  decimal 
    nupdwn.DecimalPlaces = 2
    nupdwn.ReadOnly = true
    nupdwn.TextAlign = HorizontalAlignment.Right
    AddHandler nupdwn.ValueChanged, AddressOf nupdwn_OnValueChanged
  end sub

  private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
    Console.WriteLine(hbar.Value)
    Console.WriteLine(hbar.LargeChange)
  end sub

  private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
    Console.WriteLine(vbar.Value)
    Console.WriteLine(vbar.LargeChange)
  end sub

  private sub nupdwn_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
    Console.WriteLine(nupdwn.Value)
  end sub

  public shared sub Main() 
    Application.Run(new NumericUpDowns())
  end sub
end class








14.11.NumericUpDown
14.11.1.ScrollBars - NumericUpDowns
14.11.2.Get value from the NumericUpDown controlGet value from  the NumericUpDown control