لمن يرغب في كودالتحويل وهو حق مشروع للاستخدام ونسال الله الاجر
[align=left]ConsoleTest1--------------------------------------- [align=left]
'Purpose: To convert Degree, minutes, seconds and decimal degrees to there opposites
'Organisation: Curtin University
'Project: Assignment 1
'Date: 5 May 2006
'Author: Abdullah Almahrouqi[/align]
'
'Mainline Variables:
' deg (integer) - degrees input from user
' min (integer) - minute input from user
' sec (integer) - second input from user
' decinput (single) - user input in decimal degrees
' decinput2(integer) - user input in decimal degrees
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents output As System.Windows.Forms.TextBox
Friend WithEvents Decimaldeg As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Decimaldeg = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.output = New System.Windows.Forms.TextBox
Me.Label6 = New System.Windows.Forms.Label
Me.Button3 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Decimaldeg
'
Me.Decimaldeg.Location = New System.Drawing.Point(8, 8)
Me.Decimaldeg.Name = "Decimaldeg"
Me.Decimaldeg.Size = New System.Drawing.Size(88, 20)
Me.Decimaldeg.TabIndex = 0
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Showcard Gothic", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.Black
Me.Label1.Location = New System.Drawing.Point(29, 40)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(67, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Input"
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.DarkKhaki
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.Font = New System.Drawing.Font("Perpetua Titling MT", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(118, 118)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(175, 56)
Me.Button1.TabIndex = 9
Me.Button1.Text = "Convert to DD to DMS"
Me.Button1.UseVisualStyleBackColor = False
'
'Button2
'
Me.Button2.AccessibleRole = System.Windows.Forms.AccessibleRole.IpAddress
Me.Button2.BackColor = System.Drawing.Color.Wheat
Me.Button2.Font = New System.Drawing.Font("MS Reference Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(118, 18)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(175, 56)
Me.Button2.TabIndex = 10
Me.Button2.Text = "Convert DMS to DD"
Me.Button2.UseVisualStyleBackColor = False
'
'output
'
Me.output.Location = New System.Drawing.Point(8, 154)
Me.output.Name = "output"
Me.output.Size = New System.Drawing.Size(96, 20)
Me.output.TabIndex = 11
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("Impact", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(28, 188)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(67, 27)
Me.Label6.TabIndex = 12
Me.Label6.Text = "Output"
'
'Button3
'
Me.Button3.BackColor = System.Drawing.Color.DarkOrchid
Me.Button3.Font = New System.Drawing.Font("Papyrus", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button3.ForeColor = System.Drawing.Color.Black
Me.Button3.Location = New System.Drawing.Point(190, 229)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(103, 34)
Me.Button3.TabIndex = 13
Me.Button3.Text = "Exit"
Me.Button3.UseVisualStyleBackColor = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.output)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Decimaldeg)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim DMSDeg As Double ' degrees input when entering degrees minutes and seconds
Dim DMSmin As Double ' minutes input when entering degrees minutes and seconds
Dim DMSsec As Double ' seconds input when entering degrees minutes and seconds
DMSDeg = Val(deg.Text) 'the value of the text entered in the degrees section
DMSmin = Val(min.Text / 60) ' the value of the text entered in the degrees section divided by 60
DMSsec = Val(sec.Text / 3600) ' the value of the text entered in the degrees section divided by 360
output.Text = DMSDeg & +DMSmin + DMSsec ' displaying the output in the textbox by adding the 3 values above
If DMSDeg <= 0 And DMSmin <= 0 And DMSsec <= 0 Then 'this will occur if no value is entered
MsgBox(" you have clicked the incorrect button please re-enter your information or select the other button")
output.Text = ("undefined")
Else
output.Text = DMSDeg + DMSmin / 60 + DMSsec / 3600 ' output box has angle in decimal degrees
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim decinput As Single ' A decimal munber e.g 10.51
Dim decinput2 As Integer ' will round up or down e.g 10.51 will round up(whole number)11
Dim decinput3 As Integer 'used to find out the minutes
Dim decinput4 As Integer ' used to find out the seconds
decinput = Val(Decimaldeg.Text) 'value of the number entered into the decimal degrees box
decinput2 = Val(Decimaldeg.Text) ' this is the value entered into the decimal degrees box as a whole munber
decinput3 = Val(Decimaldeg.Text) ' the value of decinput3
decinput4 = Val(Decimaldeg.Text) ' the value of decinput4
' do an if then statement
If decinput2 > decinput Then ' if decinput 2 is greater then decinput then
decinput2 = (decinput2 - 1) ' decinput2 will equal it self -1. for example if deciaml degree entered is 10.51
'decinput2 will round up to 11 making it bigger so 1 is subtracted
End If
decinput4 = (((decinput2 - 1) - decinput2) * 60) 'this finds out the seconds
decinput3 = (decinput - decinput2) * 60 'this finds out the minutes
If decinput <= 0 Then
MsgBox("Invalid User Input - Ensure correct button was clicked or value was typed in correct box")
output.Text = (" Undefined Result ") ' if nothing is entered then this message will come up in the utput box
Else
output.Text = decinput2 & "º " & Format(decinput3, "#") & "' " & decinput4 & "''" ' ' this will show the output in degrees minutes and seconds in the answer box
End If
End Sub[/align]
يا من يدعي في العلم معرفة عرفت شيئا وغابت عنك اشياء