返回列表 上一主題 發帖

vba瘦身,感恩

回復 10# sillykin

不好意思..想在請問vba瘦身

Private Sub OptionButton1_Click()
If OptionButton1 = True Then
[B58].VALUE = 1
[C58] = "國防事業"
End If
Unload Me
UserForm40.Show

End Sub

Private Sub OptionButton2_Click()
If OptionButton2 = True Then
[B58].Value = 2
[C58] = "警察單位"
End If
Unload Me
UserForm40.Show

End Sub

Private Sub OptionButton3_Click()
If OptionButton3 = True Then
[B58].Value = 3
[C58] = "其他公共行政類"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton4_Click()
If OptionButton4 = True Then
[B58].Value = 4
[C58] = "教育類"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton5_Click()
If OptionButton5 = True Then
[B58].Value = 5
[C58] = "學生"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton6_Click()
If OptionButton6 = True Then
[B58].Value = 6
[C58] = "工、商及服務類"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton7_Click()
If OptionButton7 = True Then
[B58].Value = 7
[C58] = "農林漁牧類"
End If
Unload Me
UserForm40.Show
End Sub

Private Sub OptionButton8_Click()
If OptionButton8 = True Then
[B58].Value = 8
[C58] = "礦石及土石採取業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton9_Click()
If OptionButton9 = True Then
[B58].Value = 9
[C58] = "製造業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton10_Click()
If OptionButton10 = True Then
[B58].Value = 10
[C58] = "水電燃氣業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton11_Click()
If OptionButton11 = True Then
[B58].Value = 11
[C58] = "營造業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton12_Click()
If OptionButton12 = True Then
[B58].Value = 12
[C58] = "批發及零售業"
End If
Unload Me
UserForm40.Show
End Sub
Private Sub OptionButton13_Click()
If OptionButton13 = True Then
[B58].Value = 13
[C58] = "住宿及餐飲業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton14_Click()
If OptionButton14 = True Then
[B58].Value = 14
[C58] = "運輸、倉儲及通信業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton15_Click()
If OptionButton15 = True Then
[B58].Value = 15
[C58] = "金融及保險業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton16_Click()
If OptionButton16 = True Then
[B58].Value = 16
[C58] = "不動產及租賃業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton17_Click()
If OptionButton17 = True Then
[B58].Value = 17
[C58] = "專業服務業"
End If
Unload Me
UserForm40.Show
End Sub
Private Sub OptionButton18_Click()
If OptionButton18 = True Then
[B58].Value = 18
[C58] = "技術服務業"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton19_Click()
If OptionButton19 = True Then
[B58].Value = 19
[C58] = "無業、家管、退休人員等"
End If
Unload Me
UserForm40.Show
End Sub


Private Sub OptionButton20_Click()
If OptionButton20 = True Then
[B58].Value = 20
[C58] = "不動非法人組織授信戶負責人"
End If
Unload Me
UserForm40.Show
End Sub
'===============================================================================





Private Sub UserForm_Click()

End Sub

TOP

本帖最後由 GBKEE 於 2016-2-14 15:38 編輯

回復 11# sillykin
空白的表單模組程式碼
  1. Option Explicit
  2. Dim xAr(), xClass() As New OP_Class
  3. Private Sub UserForm_Initialize()
  4.      Dim xLeft As Integer, xTop As Integer, i As Integer, Form_Height As Integer, Form_Width As Integer
  5.      Dim OB As Object
  6.      xAr = Array("國防事業", "警察單位", "其他公共行政類", "教育類", "學生", "工、商及服務類", "農林漁牧類", "AAA", "BBBB", "CCCC", "DDDDD", "EEE")
  7.      'xAr 也可以是工作表上單欄或單列的範圍
  8.      ReDim xClass(1 To UBound(xAr) + 1)
  9.      xLeft = 10: xTop = 10
  10.      For i = 1 To UBound(xAr) + 1
  11.         Set OB = Controls.Add("Forms.OptionButton.1", "OptionButton" & i)
  12.         
  13.         Set xClass(i).Op = OB
  14.         With OB
  15.             .Caption = xAr(i - 1)
  16.             .Tag = i
  17.             .Left = xLeft
  18.             .Top = xTop
  19.             .Width = 150
  20.             .Height = 20
  21.             If i Mod 10 Then
  22.                  xTop = xTop + 10 + .Height
  23.                  Form_Height = IIf(Form_Height < xTop, xTop + 10 + .Height * 2, Form_Height)
  24.             Else
  25.                 xTop = 10
  26.                 xLeft = xLeft + 10 * 2 + .Width
  27.                 Form_Width = IIf(Form_Width < xLeft, Form_Width + xLeft + .Width, Form_Width)
  28.             End If
  29.         End With
  30.      Next
  31.      '調整Form的高度,寬度
  32.      Height = Form_Height
  33.      Width = Form_Width
  34. End Sub
複製代碼
物件模組的程式碼
  1. Option Explicit
  2. Public WithEvents Op As MSForms.OptionButton
  3. Private Sub Op_Click()
  4.     'OptionButton
  5.     With Op
  6.         MsgBox .Name & vbLf & .Caption
  7.         [B58] = .Tag
  8.         [C58] = .Caption
  9.         Unload .Parent
  10.     End With
  11.     UserForm40.Show
  12. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

回復 12# GBKEE


    謝謝G大的回覆..

TOP

        靜思自在 : 多做多得。少做多失。
返回列表 上一主題