1
"길이"에 대한 변환 프로그램으로이 프로그램이 있는데, if, elseif, else를 너무 많이 유지하는 대신 가장 간단한 방법으로 어떻게 수행 할 수 있습니까? 많은 경험이 없으며 개선하기 위해 노력하고 있습니다. 비주얼 스튜디오에서 내 프로그래밍 기술 2008.Visual Studio Conversion Suite
기본적으로, 내가 옳은지 모르겠다 때문에 공식적으로 짜증이 난, 내가 사용하는 방법을 잘 모르겠지만 도움이되지 않습니다. 프로그램이 유형에서 유형으로 변환 할 때
Public Class Form2
Dim Metres As Integer
Dim Centimetres As Integer
Dim Inches As Integer
Dim Feet As Integer
Dim Total As Integer
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ErrorMsg.Hide()
End Sub
Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
Metres = 1
Centimetres = 0.01
Inches = 0.0254
Feet = 0.3048
txtTo.Text = 0
If txtFrom.Text <> "" Then
If IsNumeric(txtFrom.Text) And IsNumeric(txtTo.Text) Then
If cbFrom.Text = "Metres" And cbTo.Text = "Centimetres" Then
Total = txtFrom.Text * Metres
txtTo.Text = Total
ElseIf cbFrom.Text = "Metres" And cbTo.Text = "Inches" Then
Total = txtFrom.Text * 100
txtTo.Text = Total
ElseIf cbFrom.Text = "Metres" And cbTo.Text = "Feet" Then
ElseIf cbFrom.Text = "Centimetres" And cbTo.Text = "Metres" Then
ElseIf cbFrom.Text = "Centimetres" And cbTo.Text = "Inches" Then
ElseIf cbFrom.Text = "Centimetres" And cbTo.Text = "Feet" Then
ElseIf cbFrom.Text = "Inches" And cbTo.Text = "Metres" Then
ElseIf cbFrom.Text = "Inches" And cbTo.Text = "Centimetres" Then
ElseIf cbFrom.Text = "Inches" And cbTo.Text = "Feet" Then
ElseIf cbFrom.Text = "Feet" And cbTo.Text = "Metres" Then
ElseIf cbFrom.Text = "Feet" And cbTo.Text = "Centimetres" Then
ElseIf cbFrom.Text = "Feet" And cbTo.Text = "Inches" Then
End If
End If
End If
End Sub
End Class
이것은 현재 내가 한 작업의 출처입니다.