CAFE

활용 강좌

[081] 섭씨, 화씨 온도 변환기

작성자윤슬|작성시간10.11.19|조회수1,105 목록 댓글 1

 

안녕하세요?

 

간단한 섭씨, 화씨 온도 변환기 입니다.

이런 자료를 올려드리는 이유는 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

==========================================================================================

첨부파일

 

첨부파일 101117_화씨_섭씨_온도변환.xlsm

 

==========================================================================================

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
  • 작성자이군악 | 작성시간 17.12.23 항상 섭씨 화씨 변환은 일상이라서 굳이 함수 안만들어두어도 외우고 있습니다.
    F=C*9/5+32
    C=F*5/9-32 ㅋㅋ
댓글 전체보기
맨위로

카페 검색

카페 검색어 입력폼