OfficeTutor.com
Home ·Î±×ÀΠȸ¿ø°¡ÀÔ °í°´¼¾ÅÍ »çÀÌÆ®¸Ê
½ÃÀÛÆäÀÌÁö¼³Á¤ Áñ°Üã±âÃß°¡
¹è¿òÅÍ ³ª´®ÅÍ ±³À° MY¿ÀÆ©
 
¡¡ Home > ¹è¿òÅÍ > ¹«·á°­ÁÂ
¡¡

  

11. ¼ýÀÚ¸¦ ÇѱÛ/ÇÑÀÚ/¿µ¾î·Î º¯È¯ -¥±

ÀÌÁ¦ ÇÙ½ÉÇÔ¼ö°¡ ¸¶·ÃµÇ¾úÀ¸´Ï »ç¿ëÀÚÁ¤ÀÇÆûÀ» ¸¸µé¾î º¸°Ú½À´Ï´Ù. ÆûÀº ´ÙÀ½°ú °°½À´Ï´Ù.

»ç¿ë¹ýÀº °£´äÇÕ´Ï´Ù. À§ÀÇ ±×¸²¿¡¼­ º¸µíÀÌ NumberÅؽºÆ®»óÀÚ¿¡ ¼ýÀÚ¸¦ ÀÔ·ÂÇÏ°í Language¿¡¼­ ¹®ÀÚ¸¦ ¼±ÅÃÇϸé Preview¿¡¼­ º¯È¯µÈ °ÍÀ» º¼ ¼ö ÀÖ½À´Ï´Ù. ±×¸®°í È®ÀιöÆ°À» Ŭ¸¯Çϸé ÇöÀç ¼¿¿¡ º¯È¯µÈ ³»¿ëÀÌ µé¾î °©´Ï´Ù. ±×¸®°í Ãë¼Ò¸¦ Ŭ¸¯ÇÏ¸é ¾Æ¹« Àϵµ ¹ß»ýÇÏÁö ¾Ê½À´Ï´Ù. ±×¸®°í ÇöÀç ¼¿¿¡¼­ ÀÌ ±â´ÉÀ» ºÒ·¯³»¸é ÇöÀ缿ÀÇ ¼ýÀÚ°¡ NumberÅؽºÆ®»óÀÚ¿¡ µé¾î°¡µµ·Ï ÇØ¾ß °ÚÁÒ!

´ÙÀ½Àº À§ÀÇ »ç¿ëÀÚÁ¤ÀÇ ÆûÀÇ °¢ À̺¥Æ®¸¦ ¸¸µé¾î ³õÀº ÄÚµåÀÔ´Ï´Ù.

frmToString
Option Explicit

Private Sub btnCancel_Click()
     Unload Me
End Sub

Private Sub btnOK_Click()
     ActiveCell.Value = Preview.Caption
     Unload Me
End Sub

Private Sub opHangul_Click()

End Sub

Private Sub opHanja_Click()

End Sub

Private Sub opEnglish_Click()
     Preview.Caption = ConvertCurrencyToEnglish(txtNumber.Text)
End Sub

Private Sub txtNumber_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
     Select Case KeyAscii
     Case vbKey0 To vbKey9
     Case 46
     Case Else
          KeyAscii = 0
     End Select
End Sub

Private Sub UserForm_Activate()
     Application.EnableCancelKey = xlDisabled
     If Application.WorksheetFunction.IsNumber(ActiveCell.Value) Then txtNumber.Text =
      ActiveCell.Value
     txtNumber.SetFocus
End Sub

Private Sub btnCancel_Click()
     Unload Me
End Sub
[Ãë¼Ò]¹öÆ°À» Ŭ¸¯ÇÏ¸é ±×Àú ÇöÀçÀÇ ÆûÀ» ¾ø¾Ö¹ö¸³´Ï´Ù. Áï ¸Þ¸ð¸®¿¡¼­ Á¦°ÅÇÕ´Ï´Ù. ¸¸ÀÏ ¸Þ¸ð¸®¿¡¼­ Á¦°ÅÇÏÁö ¾Ê°í ´ÜÁö ¼û±â´Â °ÍÀ̶ó¸é Me.Hide¸¦ ÇÏ¸é µÇ°ÚÁÒ. ±×¸®°í À̸¦ ´Ù½Ã º¸ÀÌ·Á¸é Me.Show¸¦ ÇÏ¸é µË´Ï´Ù.

Private Sub btnOK_Click()
     ActiveCell.Value = Preview.Caption
     Unload Me
End Sub
[È®ÀÎ]¹öÆ°À» Ŭ¸¯ÇÏ¸é ¹Ì¸® º¸±â(Preview)ÀÇ ³»¿ë(Caption)À» ÇöÀç ¼¿¿¡ ÀÔ·ÂÇÏ°í ÆûÀ» ¾ø¾Û´Ï´Ù.

Private Sub opEnglish_Click()
     Preview.Caption = ConvertCurrencyToEnglish(txtNumber.Text)
End Sub
LanguageÀÇ ¹®ÀڿɼÇÁß [¿µ¾î]¸¦ ¼±ÅÃÇϸé ÅؽºÆ®»óÀÚÀÇ ³»¿ë(txtNumber.Text)À» ÀÌ¹Ì ±¸ÇÑ Function ConvertCurrencyToEnglish(ByVal MyNumber)ÇÔ¼ö¿¡ ÀÔ·ÂÇÏ°í ±× °á°ú¸¦ ¹Þ¾Æ ¹Ì¸® º¸±â(Preview)ÀÇ ³»¿ë(Caption)¿¡ ÀÔ·ÂÇÕ´Ï´Ù.

Private Sub txtNumber_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
     Select Case KeyAscii
     Case vbKey0 To vbKey9
     Case 46
     Case Else
          KeyAscii = 0
     End Select
End Sub
ÅؽºÆ®»óÀÚ ÄÜÆ®·ÑÀº Å°º¸µå·ÎºÎÅÍ °ªÀ» ¾ò½À´Ï´Ù. ±×·¡¼­ _KeyPressÀ̺¥Æ®°¡ °¡´ÉÇѵ¥ Áï ÅؽºÆ®»óÀÚ ÄÜÆ®·Ñ¿¡¼­ Å°º¸µå¸¦ ´©¸¦ ¶§¸¶´Ù À§ÀÇ À̺¥Æ®°¡ ¹ß»ýÇÕ´Ï´Ù. À̶§ ´©¸¥ Å° °ªÀ» ¸Å°³º¯¼ö·Î Àü´Þ¹Þ´Âµ¥ ±× º¯¼ö°¡ ¹Ù·Î KeyAsciiÀÌÁÒ. ±×¸®°í ÀÌ °ªÀº Á¤¼ö°ªÀÔ´Ï´Ù. ÀÌ °ªÀ» Çص¶ÇÏ¿© ¿ì¸®´Â ¹«½¼ Å°°¡ ´­·Á Á³´Â°¡¸¦ ¾Ë ¼ö ÀÖ½À´Ï´Ù. ¿©±â¿¡¼­´Â ¼ýÀÚ¿Í Á¡¸¸ ÀÔ·Â¹Þ°í ³ª¸ÓÁö Å°´Â ¹«½ÃÇعö·Á¾ß ÇÕ´Ï´Ù. ±×·¡¼­ ElseÀÌÇÏ¿¡¼­´Â KeyAsciiº¯¼ö°ªÀ» 0À¸·¯ ¼³Á¤ÇÏ¿© ¼ýÀÚ¿Í Á¡ÀÌ ¾Æ´Ñ ¹®ÀÚ°¡ ÅؽºÆ®»óÀÚ ÄÜÆ®·Ñ¿¡ ÀԷµÇÁö ¾Êµµ·Ï ÇÏ°í ÀÖ½À´Ï´Ù.
VB/VBA¿¡¼­´Â ÀÚÁÖ »ç¿ëÇÏ´Â ¿©·¯ Å° °ªÀ» ³»ºÎ»ó¼ö·Î ¹Ì¸® Á¤ÀÇÇØ µÎ¾ú½À´Ï´Ù. 
´ÙÀ½Àº ¼ýÀÚ Å° »ó¼ö¿Í °ªÀÔ´Ï´Ù. ±× ¿Ü ¿©·¯ °¡Áö Å°°¡ ÀÖÁö¸¸ »ý·«ÇÕ´Ï´Ù.

»ó¼ö °ª ¼³¸í
vbKey0 48 0Å°
vbKey1 49 1Å°
vbKey2 50 2Å°
vbKey3 51 3Å°
vbKey4 52 4Å°
vbKey5 53 5Å°
vbKey6 54 6Å°
vbKey7 55 7Å°
vbKey8 56 8Å°
vbKey9 57 9Å°

Private Sub UserForm_Activate()
     Application.EnableCancelKey = xlDisabled
     If Application.WorksheetFunction.IsNumber(ActiveCell.Value) Then
        txtNumber.Text =  ActiveCell.Value
    EndIF    
           txtNumber.SetFocus
End Sub

Application.EnableCancelKey = xlDisabled À̶õ Äڵ尡 Àִµ¥ »ý¼ÒÇϽŠºÐµéÀÌ °è½Ç °Ì´Ï´Ù. ÇϳªÇϳª ¶â¾î º¸¸é »ìÆ캸µµ·Ï ÇÏÁÒ. ApplicationÀ̶õ °ÍÀº ÇöÀçÀÇ VBA È£½ºÆ® ÇÁ·Î±×·¥ÀÎ ¿¢¼¿À» ÀǹÌÇÕ´Ï´Ù. CancelKey¶ó´Â ´Ü¾î´Â ¹º°¡ Ãë¼ÒÇÏ´Â Å°¶ó´Â ¶æ °°ÁÒ. ¸Â½À´Ï´Ù. ÀÌ°ÍÀº ÇÁ·Î½ÃÁ®¸¦ ÁߴܽÃÅ°´Â Ctrl+BreakÅ°(¶Ç´Â EscÅ°)¸¦ ÀǹÌÇÕ´Ï´Ù. Application.EnableCancelKey´Â ÇÁ·Î½ÃÁ®ÀÇ È帧À» ÁߴܽÃų ¼ö ÀÖ´Â Ctrl+BreakÅ°(¶Ç´Â EscÅ°)¸¦ ó¸®ÇÏ´Â ¹æ¹ýÀ» ÁöÁ¤ÇÏ´Â °ÍÀÔ´Ï´Ù. ´ÙÀ½Àº Application.EnableCancelKey¿¡ ÁöÁ¤ÇÒ ¼ö ÀÖ´Â »ó¼ö°ª°ú ÀǹÌÀÔ´Ï´Ù.

»ó¼ö ÀǹÌ
xlDisabled  Ãë¼ÒÅ°¸¦ »ç¿ëÇÒ ¼ö ¾ø°Ô µË´Ï´Ù.
xlInterrupt  ÇöÀç ÇÁ·Î½ÃÀú¸¦ ÁßÁöÇÏ¿© »ç¿ëÀÚ°¡ ÇÁ·Î½ÃÀú¸¦ µð¹ö±ëÇϰųª ³¡³¾ ¼ö ÀÖµµ·Ï ÇÕ´Ï´Ù.
xlErrorHandler ÀÎÅÍ·´Æ®°¡ ½ÇÇà ÁßÀÎ ÇÁ·Î½ÃÀú¿¡ ¿À·ù·Î Àü´ÞµÇ°í On Error GoTo ¹®À» »ç¿ëÇÏ¿© ¿À·ù 󸮱⠼³Á¤À¸·Î Â÷´ÜÇÒ ¼ö ÀÖ½À´Ï´Ù. Â÷´ÜÇÒ ¼ö ÀÖ´Â ¿À·ù ÄÚµå´Â 18¹øÀÔ´Ï´Ù.

¿¢¼¿ÀÇ µµ¿ò¸» ¿¹Á¦

On Error GoTo handleCancel
Application.EnableCancelKey = xlErrorHandler
MsgBox "ÀÌ ÀÛ¾÷Àº ¿À·¡ °É¸± °ÍÀÔ´Ï´Ù. Ãë¼ÒÇÏ·Á¸é EscÅ°¸¦ ´©¸£½Ê½Ã¿À."
For x = 1 To 1000000 'ÁöÁ¤ÇÑ ÀÛ¾÷À» ¹é¸¸ ¹øÂë(¿À·§µ¿¾È) ½ÇÇàÇÕ´Ï´Ù.
     'ÁöÁ¤ÇÑ ÀÛ¾÷À» ½ÇÇàÇÕ´Ï´Ù.
Next x

handleCancel:
If Err = 18 Then
     MsgBox "»ç¿ëÀÚ°¡ ÀÛ¾÷À» Ãë¼ÒÇß½À´Ï´Ù."
End If

À§ÀÇ ¿¹Á¦¿¡¼­´Â Application.EnableCancelKeyÅ°¿¡ xlErrorHandler¸¦ ¼³Á¤ÇÏ¿© »ç¿ëÀÚ°¡ ESCÅ°¸¦ ´©¸£¸é »ç¿ëÀÚ°¡ ¸¸µç ¿¡·¯ Çڵ鷯·Î À̵¿ÇÏ°Ô ÇÏ¿´½À´Ï´Ù. ±×¸®°í À̶§ ¿¡·¯¹øÈ£´Â 18¹øÀÌ µË´Ï´Ù. ½Ã°£ÀÌ ¿À·¡ °É¸®´Â ÀÛ¾÷¿¡ ¼º¹Ì ±ÞÇÑ »ç¿ëÀÚ¸¦ ¹è·ÁÇÏ¿© ÀÌ·¯ÇÑ ·çƾÀ» ÀüÇüÀûÀ¸·Î »ç¿ëÇÕ´Ï´Ù.

If Application.WorksheetFunction.IsNumber(ActiveCell.Value) Then 
     txtNumber.Text = ActiveCell.Value
End If
ÀÌ »ç¿ëÀÚÆûÀº ±âº»ÀûÀ¸·Î ÇöÀç ¼¿ÀÇ ³»¿ëÀ» ÅؽºÆ®»óÀÚ ÄÁÆ®·Ñ¿¡ ÀÚµ¿À¸·Î ÀÔ·ÂÇÏ°Ô²û ÇÏ°í ÀÖ½À´Ï´Ù. ±×·±µ¥ ±×·¯´Ù º¸´Ï ÇöÀç ¼¿ÀÇ ³»¿ëÀÌ ¼ýÀÚÀΰ¡ ¾Æ´Ï¸é ¹®ÀÚÀΰ¡¸¦ ÆľÇÇØÁÖ¾î ¼ýÀÚ¶ó¸é ÅؽºÆ®»óÀÚ ÄÁÆ®·Ñ¿¡ ÀÚµ¿À¸·Î ÀÔ·ÂÇÏÁö¸¸ ¹®ÀÚ¶ó¸é ¹«½ÃÇØ¾ß ÇÕ´Ï´Ù. ÀÌ·¯ÇÑ ÆÇ´ÜÀº ¿¢¼¿ÀÇ ¿öÅ©½ÃÆ® ÇÔ¼öÀÎ IsNumber()ÇÔ¼ö¸¦ ÀÌ¿ëÇÕ´Ï´Ù. ¿¢¼¿ÀÇ ¿öÅ©½ÃÆ®ÇÔ¼ö¿¡ Á¢±ÙÇÏ·Á¸é Application.WorksheetFunctionÀ» ÅëÇØ¾ß ÇÕ´Ï´Ù.

¿À´ÃÀº ¿©±â±îÁö ÀÔ´Ï´Ù. ´ÙÀ½ ½Ã°£¿£ ¼ýÀÚ¸¦ Çѱ۷Πº¯È¯ÇÏ´Â ÇÔ¼ö¸¦ ¼Ò°³ÇÏ°Ú½À´Ï´Ù.

¸ñÂ÷ | ÀÌÀü | ´ÙÀ½

¡¡

ȸ»ç¼Ò°³ | ÀÌ¿ë¾à°ü | °³ÀÎÁ¤º¸ º¸È£Á¤Ã¥ | ȸ¿øÁ¤º¸¼öÁ¤ | ±³À°½Åû ¹× ¹®ÀÇ | À̸ÞÀϹ«´Ü¼öÁý°ÅºÎ 
   (¿ì)143-721 ¼­¿ï ±¤Áø±¸ ±¸Àǵ¿ 546-4 Å×Å©³ë¸¶Æ® 26Ãþ6È£
¢ß¿ÀÇǽºÆ©ÅÍ ¢Ï1544-4102  ´ëÇ¥ÀÌ»ç : Àü°æ¼ö
°³ÀÎÁ¤º¸°ü¸®Ã¥ÀÓÀÚ : ÀÌÈñÁø(privacy@officetutor.com)
»ç¾÷ÀÚµî·Ï¹øÈ£ 120-86-14501 Åë½ÅÆǸž÷½Å°í ±¤Áø1501È£
 
Copyright ¨Ï OfficeTutor.com ÀÌ ÆäÀÌÁöÀÇ ÀúÀÛ±ÇÀº ¢ß¿ÀÇǽºÆ©ÅÍ¿Í ÄÁÅÙÃ÷ Á¦°øÀÚ¿¡°Ô ÀÖ½À´Ï´Ù. ¹«´Ü º¹Á¦¸¦ ±ÝÇÕ´Ï´Ù.
Microsoft ¹× Office ·Î°í´Â ¹Ì±¹, ´ëÇѹα¹ ¹×/¶Ç´Â ±âŸ ±¹°¡¿¡¼­ÀÇ Microsoft Corporation µî·Ï »óÇ¥ ¶Ç´Â »óÇ¥ÀÔ´Ï´Ù.