标题:SkinH_Attach 未定义,大神赐教。
只看楼主
我不会VB
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-16
结帖率:0
已结贴  问题点数:20 回复次数:6 
SkinH_Attach 未定义,大神赐教。
Private Sub Command1_Click()

Dim timer_clk As Double
Dim Ts As Double
Dim f_out As Double
Dim ModulationDepth As Double

Const PI = 3.141592654
Const PARA = 0.866025403

Dim TBCCR0 As Integer
Dim Dimension As Integer
Dim SVcounter As Integer
Dim SV_T1 As Double
Dim SV_T2 As Double
Dim SV_T0 As Double


TBCCR0 = 0
Dimension = 0
SVcounter = 0
SV_T1 = 0
SV_T2 = 0
SV_T0 = 0


timer_clk = Val(Text1.Text)
Ts = Val(Text2.Text)
f_out = Val(Text3.Text)
ModulationDepth = Val(Text4.Text)

Text5.Text = ""

'计算TBCCR0
TBCCR0 = 0.5 * 1000 * timer_clk / Ts
'计算数组长度
Dimension = 1000 * Ts / f_out

'显示参数资信
Text5.FontBold = False
Text5.FontSize = 10
Text5.Text = "The results are :" & vbCrLf
Text5.Text = Text5.Text + "    TBCCR0 = " & Str(TBCCR0) & vbCrLf
Text5.Text = Text5.Text + "    the length of array = " & Str(Dimension) & vbCrLf & vbCrLf
Text5.Text = Text5.Text + "With following conditions: " & vbCrLf
Text5.Text = Text5.Text + "    Timer clock = " & Str(timer_clk) & " MHz;" & vbCrLf
Text5.Text = Text5.Text + "    the frequency of each pulse circle = " & Str(Ts) & " kHz" & vbCrLf
Text5.Text = Text5.Text + "    the frequency of output = " & Str(f_out) & " Hz" & vbCrLf
Text5.Text = Text5.Text + "    the modulation depth = " & Format(Str(ModulationDepth), "0.000") & vbCrLf & vbCrLf
Text5.Text = Text5.Text + "The arrays are :" & vbCrLf


Dim SV_cmp1() As Double
Dim SV_cmp2() As Double
Dim SV_cmp3() As Double
Dim SV_PHA() As Integer
Dim SV_PHB() As Integer
Dim SV_PHC() As Integer

ReDim SV_cmp1(Dimension)
ReDim SV_cmp2(Dimension)
ReDim SV_cmp3(Dimension)
ReDim SV_PHA(Dimension)
ReDim SV_PHB(Dimension)
ReDim SV_PHC(Dimension)






For SVcounter = 0 To Dimension - 1 Step 1
    '第一扇区
    If SVcounter <= (Dimension * 1 / 6 - 1) And SVcounter >= 0 Then
        SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 1 / 6)
        SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 9 / 6)
        SV_T0 = (1 - SV_T1 - SV_T2) / 2
        
        SV_cmp1(SVcounter) = SV_T1 + SV_T2 + SV_T0
        SV_cmp2(SVcounter) = SV_T2 + SV_T0
        SV_cmp3(SVcounter) = SV_T0
        
        SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
        SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
        SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
    End If
   
    '第二扇区
    If SVcounter <= (Dimension * 2 / 6 - 1) And SVcounter >= (Dimension * 1 / 6) Then
        SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 11 / 6)
        SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 7 / 6)
        SV_T0 = (1 - SV_T1 - SV_T2) / 2
        
        SV_cmp1(SVcounter) = SV_T1 + SV_T0
        SV_cmp2(SVcounter) = SV_T1 + SV_T2 + SV_T0
        SV_cmp3(SVcounter) = SV_T0
        
        SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
        SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
        SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
    End If
   
    '第三扇区
    If SVcounter <= (Dimension * 3 / 6 - 1) And SVcounter >= (Dimension * 2 / 6) Then
        SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 9 / 6)
        SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 5 / 6)
        SV_T0 = (1 - SV_T1 - SV_T2) / 2
        
        SV_cmp1(SVcounter) = SV_T0
        SV_cmp2(SVcounter) = SV_T1 + SV_T2 + SV_T0
        SV_cmp3(SVcounter) = SV_T2 + SV_T0
        
        SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
        SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
        SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
    End If
   
    '第四扇区
    If SVcounter <= (Dimension * 4 / 6 - 1) And SVcounter >= (Dimension * 3 / 6) Then
        SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 7 / 6)
        SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 3 / 6)
        SV_T0 = (1 - SV_T1 - SV_T2) / 2
        
        SV_cmp1(SVcounter) = SV_T0
        SV_cmp2(SVcounter) = SV_T1 + SV_T0
        SV_cmp3(SVcounter) = SV_T1 + SV_T2 + SV_T0
        
        SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
        SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
        SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
    End If
   
    '第五扇区
    If SVcounter <= (Dimension * 5 / 6 - 1) And SVcounter >= (Dimension * 4 / 6) Then
        SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 5 / 6)
        SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 1 / 6)
        SV_T0 = (1 - SV_T1 - SV_T2) / 2
        
        SV_cmp1(SVcounter) = SV_T2 + SV_T0
        SV_cmp2(SVcounter) = SV_T0
        SV_cmp3(SVcounter) = SV_T1 + SV_T2 + SV_T0
        
        SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
        SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
        SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
    End If
   
    '第六扇区
    If SVcounter <= (Dimension * 6 / 6 - 1) And SVcounter >= (Dimension * 5 / 6) Then
        SV_T1 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 3 / 6)
        SV_T2 = PARA * ModulationDepth * Cos(2 * PI * (SVcounter / Dimension) + PI * 11 / 6)
        SV_T0 = (1 - SV_T1 - SV_T2) / 2
        
        SV_cmp1(SVcounter) = SV_T1 + SV_T2 + SV_T0
        SV_cmp2(SVcounter) = SV_T0
        SV_cmp3(SVcounter) = SV_T1 + SV_T0
        
        SV_PHA(SVcounter) = Int((1 - SV_cmp1(SVcounter)) * TBCCR0 + 0.5)
        SV_PHB(SVcounter) = Int((1 - SV_cmp2(SVcounter)) * TBCCR0 + 0.5)
        SV_PHC(SVcounter) = Int((1 - SV_cmp3(SVcounter)) * TBCCR0 + 0.5)
    End If
Next SVcounter





Text5.Text = Text5.Text & "unsigned int TB_CCR_A[" & Str(Dimension) & " ] ={" & vbCrLf
For SVcounter = 0 To Dimension - 1 Step 1
    Text5.Text = Text5.Text & Str(SV_PHA(SVcounter)) & ","
    If SVcounter Mod 10 = 9 Then
        Text5.Text = Text5.Text & vbCrLf
    End If
Next SVcounter
Text5.Text = Text5.Text & "};" & vbCrLf


Text5.Text = Text5.Text & "unsigned int TB_CCR_B[" & Str(Dimension) & " ] ={" & vbCrLf
For SVcounter = 0 To Dimension - 1 Step 1
    Text5.Text = Text5.Text & Str(SV_PHB(SVcounter)) & ","
    If SVcounter Mod 10 = 9 Then
        Text5.Text = Text5.Text & vbCrLf
    End If
Next SVcounter
Text5.Text = Text5.Text & "};" & vbCrLf


Text5.Text = Text5.Text & "unsigned int TB_CCR_C[" & Str(Dimension) & " ] ={" & vbCrLf
For SVcounter = 0 To Dimension - 1 Step 1
    Text5.Text = Text5.Text & Str(SV_PHC(SVcounter)) & ","
    If SVcounter Mod 10 = 9 Then
        Text5.Text = Text5.Text & vbCrLf
    End If
Next SVcounter
Text5.Text = Text5.Text & "};" & vbCrLf



End Sub


Private Sub Command2_Click()

Open "SVresult.txt" For Output As #1
Print #1, Text5.Text
Close #1

End Sub

Private Sub Text1_Change()

End Sub

Private Sub Timer1_Timer()
Cls
Label9.Caption = Now

End Sub





Private Sub Form_Load()
SkinH_Attach

Timer1.Interval = 500
Timer1.Enabled = True
Label9.Caption = Now

End Sub
2014-04-16 17:41
我不会VB
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-16
得分:0 
调试的时候提示(SkinH_Attach未定义,)。我是雪白的是个痴,点都不会。HELP
2014-04-16 17:43
我不会VB
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-16
得分:0 
调试的时候提示(SkinH_Attach未定义,)。我是雪白的是个痴,点都不会。HELP
2014-04-16 17:43
我不会VB
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-16
得分:0 
哦,不对,是。。。。。。子程序或函数未定义
2014-04-16 17:45
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
得分:10 
不想用皮肤注释掉就行了。那是某皮肤的激活函数。
2014-04-16 19:18
chen3523
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:33
帖 子:223
专家分:1165
注 册:2013-2-12
得分:10 
Private Sub Form_Load()
SkinH_Attach  
'应该是在这问题,当程序启动时马上调用了SkinH_Attach的子程序。如果多个窗口调用此子程序,那么把它放在模块中。如果仅一个窗口调用可以放在“通用”中。如果仅一次调用可以点击“工具”→点击“添加过程”→在名称中输入“SkinH_Attach” →点击“确定”,在相应的窗口中输入编码就可以了。
End Sub

调试失败3次后,关机睡觉,当醒来时多有收获。
2014-04-16 19:33
我不会VB
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-4-16
得分:0 
回复 5 楼 bczgvip
就是,干脆去掉算咯。试试看
2014-04-16 22:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-430190-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.338389 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved