ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ½Ð±ÐUserForm¤º¦³¦h­ÓTextBox­n¦p¦ó²¤Æµ{§Ç(·PÁÂ)

[µo°Ý] ½Ð±ÐUserForm¤º¦³¦h­ÓTextBox­n¦p¦ó²¤Æµ{§Ç(·PÁÂ)

¥Ø«e¦³70­ÓTextBox¨Ã¥H²Ä70¬°1~69ªº²Ö­p
¿é¤JTextBox¨Ã«ö¤UEnter«á´N­p¤J¨ìTextBox70¤º¦]¦¹¦bµ{§Ç¤º¼g¤J¥H¤U69­Óµ{§Ç
½Ð±Ð¦p¦ó²¤Æ

¥Ø«e©|¶·¥[¤J
1.«ö¤U·Æ¹««á²MªÅTextBox¤º®e
2.«ö¤UÁä½L"©¹¤WÁä","©¹¤UÁä"
¦]¦¹µ{§Ç·|Åܱo«Üªø©Ò¥H¯S¨Ó½Ð±Ð²¤Æ¤è¦¡.....·P®¦
  1. Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  2. If KeyCode = 13 Then TextBox70.Text = Val(TextBox70.Text) + Val(TextBox1.Text)
  3. End Sub

  4. Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  5. If KeyCode = 13 Then TextBox70.Text = Val(TextBox70.Text) + Val(TextBox2.Text)
  6. End Sub
  7. .......
½Æ»s¥N½X

¦^´_ 1# changxxx



UserFormªºµ{¦¡½X
  1. Option Explicit
  2. Dim UserForm_Text(1 To 69) As New Class1 '«Å§iÅܼƬ°·sªºª«¥ó¼Ò²Õ
  3. Private Sub UserForm_Initialize()
  4.     Dim i As Integer
  5.     For i = 1 To UBound(UserForm_Text)
  6.         Set UserForm_Text(i).Class_TextBox = Controls("textbox" & i)
  7.         'ª«¥ó¼Ò²ÕªºClass_TextBox ³]©w¬° Controls("textbox" & i)
  8.     Next
  9. End Sub
½Æ»s¥N½X
ª«¥óÃþ§O¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Public WithEvents Class_TextBox As MSForms.TextBox
  3. 'WithEvents ¿ï¾Ü©Ê¤Þ¼Æ¡Cªí¥Ü varname ¬Oª«¥óÅܼƪºÃöÁä¦r¡A¥B¥Î¨Ó¹ïÀ³ ActiveX ª«¥ó©Ò¤Þµoªº¨Æ¥ó¡C
  4. '¶È¾A¥Î©óª«¥óÃþ§O¼Ò²Õ¤¤¡C
  5. '±z¥i¥H¥Î WithEvents ¨Ó­Ó§O«Å§iÅܼơA¦ý¤£¥i¥Î¨Ó«Ø¥ß°}¦C¡A¤]¤£¥i»P New ¦P®É¨Ï¥Î¡C
  6. Private Sub Class_TextBox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  7.     With Class_TextBox
  8.         If KeyCode = 13 Then .Parent.TextBox70.Text = Val(.Parent.TextBox70.Text) + Val(.Text)
  9.     End With
  10. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

:loveliness: .....«D±`·PÁÂG¤j¼ö±¡À°¦£

³ø§i:«D±`¦¨¥\


TOP

¤SµL¨B¤F...¥u¦n¦A¦¸¨D§UG¤j
·PÁ¸U¤À

¥Ø«e·Q³]¸m
TextBox70¬°1¨ì23ªº²Ö­p
TextBox71¬°24¨ì46ªº²Ö­p
TextBox72¬°47¨ì69ªº²Ö­p
¤£ª¾­n¦p¦ó­×§ïµ{§Ç......ÁÂÁ±z

TOP

¥Ø«e¥u·|¼g¦¨³o¼Ë
  1.     spTB = Val(Replace(Class_TextBox.Name, "TextBox", ""))
  2.     With Class_TextBox
  3.         If KeyCode = 13 Then
  4.             If spTB < 24 Then
  5.                 .Parent.TextBox70.Text = Val(.Parent.TextBox70.Text) + Val(.Text)
  6.             ElseIf spTB > 23 And spTB < 47 Then
  7.                 .Parent.TextBox71.Text = Val(.Parent.TextBox71.Text) + Val(.Text)
  8.             Else
  9.                 .Parent.TextBox72.Text = Val(.Parent.TextBox72.Text) + Val(.Text)
  10.             End If
  11.         End If
  12.     End With
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ linyancheng ©ó 2015-2-20 18:01 ½s¿è

³o¼Ë¼gÀ³¸Ó¥i¥H¡C

TOP

        ÀR«ä¦Û¦b : °ß¨ä´L­«¦Û¤vªº¤H¡A¤~§ó«i©óÁY¤p¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD