未完成--VBA---多个userform之间封闭,无法传递变量,很蛋疼

这篇博客探讨了在VBA中将特定界面转换为通用界面遇到的问题,包括不同窗体间的数据传递难题、控制显示效果的复杂性以及跨窗体通信的限制。作者展示了尝试解决这些问题的代码片段,并表达了对于VBA在这种情况下可能存在的局限性的疑问。博客还包含了对事件处理和逻辑控制的详细实现,例如图像点击事件和技能学习功能。
摘要由CSDN通过智能技术生成

下面得代码针对form2的老界面,也不用删,现在改到通用界面上

做不到

'最好和宠物包裹写一样,现在两套,看看处理逻辑差异多大,另外,必须回到本form写,其他form传不过去
'这样应该也不行 UserForm1.Controls("image" & i + 10).Picture() = LoadPicture(ThisWorkbook.Path & "\res\skill\" & icon3 & ".jpg")

下面得代码实验过了还是不行

1 还是缺, userform2得技能显示 show_skill得逻辑

2 跨2个form,1是无法通信

3 跨2个 form 多个页面得叠加,显示,控制显示效果也不好弄

是不是只有VBA这么挫呢

'''vba 两个不同得form传递数据不行,这个只能写在对应得业务逻辑处理页面
''' 之后查查怎么才能改到通用界面上
'''Private Sub MultiPage2_Enter()
'''    Call fresh_itembag
'''End Sub
'''
'''Function fresh_itembag()
'''
'''    r3 = Worksheets("itembag").Range("a999").End(xlUp).Row
'''    For i = 1 To r3 - 2
'''        icon3 = Application.index(Worksheets("itembag").Range("c:c"), Application.Match(i, Worksheets("itembag").Range("a:a"), 0))
'''
'''        item_id3 = Application.index(Worksheets("itembag").Range("b:b"), Application.Match(i, Worksheets("itembag").Range("a:a"), 0))
'''        skill_id3 = Application.index(Worksheets("itembag").Range("e:e"), Application.Match(i, Worksheets("itembag").Range("a:a"), 0))
'''
'''       e1 = Application.Match("技能ID", Worksheets("Petskill").Range("2:2"), 0)
'''       e222 = Application.Match("品质", Worksheets("Petskill").Range("2:2"), 0)
'''       e3 = Application.Match("技能名", Worksheets("Petskill").Range("2:2"), 0)
'''       e4 = Application.Match("技能效果", Worksheets("Petskill").Range("2:2"), 0)
'''
'''       skill_type3 = Application.index(Worksheets("Petskill").Columns(e222), Application.Match(skill_id3, Worksheets("Petskill").Columns(e1), 0))
'''       skill_name3 = Application.index(Worksheets("Petskill").Columns(e3), Application.Match(skill_id3, Worksheets("Petskill").Columns(e1), 0))
'''       skill_pro3 = Application.index(Worksheets("Petskill").Columns(e4), Application.Match(skill_id3, Worksheets("Petskill").Columns(e1), 0))
'''
'''        Controls("image" & i + 10).Picture() = LoadPicture(ThisWorkbook.Path & "\res\skill\" & icon3 & ".jpg")
'''        Controls("image" & i + 10).PictureSizeMode = fmPictureSizeModeZoom
'''        Controls("image" & i + 10).ControlTipText = skill_name3 & ":  " & Chr(10) & skill_pro3
'''
'''        If skill_type3 = 1 Then
'''           Controls("image" & 10 + i).BorderColor = RGB(0, 0, 255)
'''        ElseIf skill_type3 = 2 Then
'''           Controls("image" & 10 + i).BorderColor = RGB(255, 165, 0)
'''        Else
'''           Debug.Print "品质有错"
'''        End If
'''    Next
'''
'''End Function
'''
'''
'''Private Sub Image11_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(1)
'''
'''End Sub
'''
'''Private Sub Image12_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(2)
'''
'''End Sub
'''
'''Private Sub Image13_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(3)
'''
'''End Sub
'''
'''Private Sub Image14_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(4)
'''
'''End Sub
'''
'''Private Sub Image15_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(5)
'''
'''End Sub
'''
'''Private Sub Image16_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(6)
'''
'''End Sub
'''
'''Private Sub Image17_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(7)
'''
'''End Sub
'''
'''Private Sub Image18_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(8)
'''
'''End Sub
'''
'''Private Sub Image19_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'''   Call jump2(9)
'''
'''End Sub
'''
'''
'''Function jump2(a)
''''还没做技能书道具消耗
'''
'''   input1 = MsgBox("确定要学习这本技能书?", vbYesNo, "学习后会消耗此技能书  ")
'''
'''   If input1 = vbYes Then
'''       index2 = a
'''       Worksheets("itembag").Cells(2, 8) = index2
'''       Call learn_skill1
'''       Call show_skill1
'''   Else
'''   End If
'''
'''End Function
'''
'''
'''Function learn_skill1()
'''
'''    index2 = Worksheets("itembag").Cells(2, 8)
'''    f1 = Application.Match("对应技能", Worksheets("itembag").Range("2:2"), 0)
'''    skill_id4 = Application.index(Worksheets("itembag").Columns(f1), Application.Match(index2, Worksheets("itembag").Range("a:a"), 0))
'''
'''    f2 = Application.Match("技能1", Worksheets("petbag").Range("2:2"), 0)
'''    f3 = Application.Match("技能数量", Worksheets("petbag").Range("2:2"), 0)
'''    skill_num1 = Worksheets("petbag").Cells(index1 + 2, f3)
'''
'''    e1 = Application.Match("技能id", Worksheets("Petskill").Range("2:2"), 0)
'''    e2 = Application.Match("品质", Worksheets("Petskill").Range("2:2"), 0)
'''    e3 = Application.Match("技能名", Worksheets("Petskill").Range("2:2"), 0)
'''    e4 = Application.Match("技能效果", Worksheets("Petskill").Range("2:2"), 0)
'''
'''    skill_type4 = Application.index(Worksheets("Petskill").Columns(e2), Application.Match(skill_id4, Worksheets("Petskill").Columns(e1), 0))
'''    skill_name4 = Application.index(Worksheets("Petskill").Columns(e3), Application.Match(skill_id4, Worksheets("Petskill").Columns(e1), 0))
'''    skill_pro4 = Application.index(Worksheets("Petskill").Columns(e4), Application.Match(skill_id4, Worksheets("Petskill").Columns(e1), 0))
'''
'''    Randomize
'''    p4 = Int(1 + skill_num1 * Rnd)
'''
'''    skill_id30 = Worksheets("petbag").Cells(index1 + 2, f2).Offset(0, p4 - 1)
'''    skill_type30 = Application.index(Worksheets("Petskill").Columns(e2), Application.Match(skill_id30, Worksheets("Petskill").Columns(e1), 0))
'''    skill_name30 = Application.index(Worksheets("Petskill").Columns(e3), Application.Match(skill_id30, Worksheets("Petskill").Columns(e1), 0))
'''    skill_pro30 = Application.index(Worksheets("Petskill").Columns(e4), Application.Match(skill_id30, Worksheets("Petskill").Columns(e1), 0))
'''
'''    Worksheets("petbag").Cells(index1 + 2, f2).Offset(0, p4 - 1) = skill_id4
'''
'''    Label74.Visible = True
'''    Label74.Caption = "成功学习技能:" & Chr(10) & skill_pro4 & Chr(10) & Chr(10) & "替换掉第" & p4 & "个技能:" & Chr(10) & skill_pro30 & Chr(10) & Chr(10)
'''
'''    Label74.BackColor = RGB(255, 255, 0)
'''    Call delay1(2)
'''    Label74.Visible = False
'''
'''
'''End Function
'''
'''
'''
'''Private Sub CommandButton13_Click()
'''     MultiPage3.Visible = False
'''End Sub
'''
'''

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值