Vb.net calculadora de distância de frets para quem quiser construir uma guitarra
434 palavras
2 páginas
Form1.vbImports System.Drawing
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)
Handles Button1.Click base() Dim A As Decimal = 0
Dim X As Decimal = 0
' Input("Scale length? ", S)
Dim s As Decimal = scale.Value
Dim N As Integer = frets.Value
'Input("# of frets ", N)
TextBox1.Text = "Fret distances from the nut" & vbCrLf
TextBox1.Text += "Scale length: " & s & " mm" & vbCrLf
TextBox1.Text += vbCrLf
Dim l As Decimal = 0
For B = 1 To N l=s-A X = l / 17.817
A=A+X
linha(A, scale.Value, B)
TextBox1.Text += "Distance to fret " & B & ": " & Math.Round(A, 2) &
" mm" & vbCrLf
Next B
End Sub
Private
Integer)
Dim
Dim
Dim
Sub linha(ByVal dist As Decimal, ByVal lenght As Integer, ByVal F As g As Graphics = Panel1.CreateGraphics p As New Pen(Color.Red, 2)
ND As Integer = (dist * 950) / lenght
g.DrawLine(p, 1000 - ND, 20, 1000 - ND, 150)
Dim a As Double a = F Mod 2
If a = 0 Then
g.DrawString(Math.Round(dist, 2).ToString, New Font("verdana", 6),
Brushes.Red, New Point(1000 - ND - 6, 10))
Else
g.DrawString(Math.Round(dist, 2).ToString, New Font("verdana", 6),
Brushes.Red, New Point(1000 - ND - 6, 155))
End If
End Sub
Private Sub base()
Dim g As Graphics = Panel1.CreateGraphics
g.FillRectangle(Brushes.White, New Rectangle(0, 0, 1000, 500))
Dim p As New Pen(Color.Brown, 2)
'g.FillRectangle(Brushes.Brown, New Rectangle(10, 10, 560, 120))
g.DrawLine(p, 0, 30, 1000, 40)
g.DrawLine(p, 0, 140, 1000, 130)
g.DrawLine(p, 1000, 40, 1000, 130)
'' fazer o enchimento castanho
'For k As Integer = 0 To 110
'
For w As Integer = 0 To 90
'
g.DrawLine(p, 10, 10 + k, 570, 20 + w)
'
Next
'Next
End Sub
Page 1
Form1.vb
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As
System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex = 0 Then frets.Value = 24 scale.Value = 609.6
End If
If ComboBox1.SelectedIndex = 1 Then frets.Value = 24