00141 20150528 자작 진수 변환기 - AngryQA/blog GitHub Wiki

[자작] 진수 변환기

AngryQA | 2015-05-28 목요일 오후 5:53 | 미분류 /ETC / 읽어볼면한 / 분류전 | 원본

C#으로 제작한 진수 변환기 입니다

차차 바이트 배열을 10진수로 변경하는 기능도 추가 예정입니다

WindowsFormsApplication2.exe

|

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

|

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace WindowsFormsApplication2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            try

            {

                int decimalNum = Convert.ToInt32(textBox1.Text);

                String hexadecimalNum = Convert.ToString(decimalNum, 16);

                String binaryNum = Convert.ToString(decimalNum, 2);

                String octalNum = Convert.ToString(decimalNum, 8);

                textBox2.Text = hexadecimalNum;

                textBox3.Text = binaryNum;

                textBox4.Text = octalNum;

            }

            catch (FormatException)

            {

                textBox2.Text = "FormatException";

                textBox3.Text = "FormatException";

                textBox4.Text = "FormatException";

            }

            catch (OverflowException)

            {

                textBox2.Text = "OverflowException";

                textBox3.Text = "OverflowException";

                textBox4.Text = "OverflowException";

            }

            catch (OutOfMemoryException)

            {

                textBox2.Text = "OutOfMemoryException";

                textBox3.Text = "OutOfMemoryException";

                textBox4.Text = "OutOfMemoryException";

            }

        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)

        {

            if(!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back)))

            {

                e.Handled = true;

            }

        }

        private void button2_Click(object sender, EventArgs e)

        {

            try

            {

                int hexadecimalNum_dec = Int32.Parse(textBox5.Text, System.Globalization.NumberStyles.HexNumber);

                String decimalNum = Convert.ToString(hexadecimalNum_dec);

                textBox6.Text = decimalNum;

            }

            catch (FormatException)

            {

                textBox6.Text = "FormatException";

            }

            catch (OverflowException)

            {

                textBox6.Text = "OverflowException";

            }

            catch (OutOfMemoryException)

            {

                textBox6.Text = "OutOfMemoryException";

            }

        }

    }

}

Colored by Color Scripter

| cs |

Attachments(1)

Comments

버그버그!

Beenbyoon | 2015-05-31 일요일 오후 10:11

--

버그 왠만한건 다 잡았음!

일원동 너구리 | 2015-06-01 월요일 오후 3:50

--