안녕하세요?
간단한 섭씨, 화씨 온도 변환기 입니다.
이런 자료를 올려드리는 이유는 VBA를 공부하시면 아주 간단한 코딩만으로도 이렇게 재밌는걸 만들 수 있는걸 보여드리기 위함입니다.
첨부파일을 열어 보시고 코드를 보시면 금방 이해가 되실겁니다.
아래는 첨부파일에 사용된 코드입니다.
==========================================================================================
Option Explicit
Private Sub CommandButton1_Click()
With Me
Select Case True
Case .OptionButton1
MsgBox "섭씨 " & Format(Fahrenheit(TextBox1.Value), "#,##0.00") & " 도 입니다.", vbInformation, "재밌는 엑셀(http://cafe.daum.net/funnyexcel)"
Case .OptionButton2
MsgBox "화씨 " & Format(Celcius(TextBox1.Value), "#,##0.00") & " 도 입니다.", vbInformation, "재밌는 엑셀(http://cafe.daum.net/funnyexcel)"
End Select
End With
If MsgBox("또 다시 화씨, 섭씨를 변환하시겠습니까?", vbYesNo + vbQuestion, "재 입력 여부") = vbNo Then
Unload Me
Else
Me.TextBox1.Value = ""
End If
End Sub
Private Sub OptionButton1_Click()
Me.TextBox1.Value = ""
Me.Label1.Caption = "화씨 입력"
End Sub
Private Sub OptionButton2_Click()
Me.TextBox1.Value = ""
Me.Label1.Caption = "섭씨 입력"
End Sub
Private Sub UserForm_Initialize()
With Me
.OptionButton1.Value = True
.Label1.Caption = "화씨 입력"
End With
End Sub
==========================================================================================
Option Explicit
Sub Test()
UserForm1.Show
End Sub
Function Fahrenheit(Fahrenheit_Degree)
Fahrenheit = (Fahrenheit_Degree - 32) * 5 / 9
End Function
Function Celcius(Celcius_Degree)
Celcius = (Celcius_Degree * 1.8) + 32
End Function
==========================================================================================
첨부파일
==========================================================================================