| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1215 人关注过本帖
标题:调用子工程时,一个实参是自定义机构数组,为什么调用老出错呢?
只看楼主 加入收藏
木吉他ll
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:11 
调用子工程时,一个实参是自定义机构数组,为什么调用老出错呢?
Call interpolation(Param(10).MOE, TAverage, E)
为什么总是弹出类型不匹配:缺少数组或用户定义类型
但是我已经定义过了
Private Type DataBase
MOE As Single
PR As Single
K As Single
HOT As Single
Drift As Single
Creep As Single
End Type
dim param(10) as database
搜索更多相关主题的帖子: 工程 database 用户 
2013-04-24 10:09
xbj_hyml
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:24
专家分:114
注 册:2012-11-28
收藏
得分:5 
能不能附上 一段全一点的代码
    因为我用你这些代码 测了下 没什么错误...

懂点基础--好多控件不知道--NB代码不会写--所以一直求教中...
2013-04-24 11:40
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
收藏
得分:5 
interpolation原形?

无知
2013-04-24 12:37
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:5 
Call interpolation(Param(10).MOE, TAverage, E)

看你的传进去的参数,全是 具体的 参数,没有传数组进去。

interpolation 的定义是什么??

授人于鱼,不如授人于渔
早已停用QQ了
2013-04-24 15:20
木吉他ll
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-24
收藏
得分:0 
回复 2楼 xbj_hyml
Public Sub interpolation(Data() As Single, ByVal T As Single, ByRef Y As Single)

   Dim TT(10) As Integer                     '数据库里边的温度数组
   Dim h(9) As Single
   Dim u(1 To 9) As Single
   Dim λ(1 To 9) As Single
   Dim g(10) As Single
   Dim i As Integer
   Dim j As Integer
   Dim yy0 As Single                         '边界条件
   Dim yy10 As Single                        '边界条件
   Dim gmm As Single                         '中间变量
   Dim p As Single                           '中间变量
   Dim q As Single                           '中间变量
   Dim m(10) As Single                       '解空间
   Dim aa(0 To 10, 0 To 10) As Single        '系数矩阵

   yy0 = 0                                  '自然边界条件
   yy10 = 0

   TT(0) = 20
   TT(1) = 100
   TT(2) = 200
   TT(3) = 300
   TT(4) = 400
   TT(5) = 500
   TT(6) = 600
   TT(7) = 700
   TT(8) = 800
   TT(9) = 900
   TT(10) = 1000

   For i = 0 To 9 Step 1
       h(i) = TT(i + 1) - TT(i)
   Next i
 
   For i = 1 To 9 Step 1
       u(i) = h(i - 1) / (h(i - 1) + h(i))
   Next i

   For i = 1 To 9 Step 1
      λ(i) = h(i) / (h(i - 1) + h(i))
   Next i

   For i = 1 To 9
       gmm = (Data(i + 1) - Data(i)) / h(i) - (Data(i) - Data(i - 1)) / h(i - 1)
       g(i) = 6 * gmm / (h(i) + h(i - 1))
   Next i
   
   g(0) = 6 * ((Data(1) - Data(0)) / h(0) - yy0) / h(0)
   g(10) = 6 * (yy10 - (Data(10) - Data(9)) / h(9)) / h(9)
   
   For i = 0 To 10                     '系数矩阵清零
       For j = 0 To 10
           aa(i, j) = 0
       Next j
   Next i

   aa(0, 0) = 2                       '为系数矩阵赋值
   aa(0, 1) = 1

   For i = 1 To 9
       aa(i, i) = 2
       aa(i, i - 1) = u(i)
       aa(i, i + 1) = λ(i)
   Next i

   aa(10, 9) = 1
   aa(10, 10) = 2
   
   For i = 1 To 10                    '矩阵的对角化
       p = aa(i - 1, i - 1) / aa(i, i - 1)
       g(i) = g(i) * p - g(i - 1)
       For j = 0 To 10
           aa(i, j) = aa(i, j) * p - aa(i - 1, j)
       Next j
   Next i

   m(10) = g(10) / aa(10, 10)
   For i = 9 To 0 Step -1
       q = 0
       For j = 10 To i + 1 Step -1
           q = q + aa(i, j) * m(j)
       Next j
       m(i) = (g(i) - q) / aa(i, i)
   Next i

   For i = 0 To 9
       If T >= TT(i) And T <= TT(i + 1) Then
          Y = (m(i) * (TT(i + 1) - T) ^ 3) / (6 * h(i)) + (m(i + 1) * (T - TT(i)) ^ 3) / (6 * h(i)) + (Data(i) - (m(i) * h(i) ^ 2) / 6) * (TT(i + 1) - T) / h(i) + (Data(i + 1) - (m(i + 1) * h(i) ^ 2) / 6) * (T - TT(i)) / h(i)
       End If
   Next i

End Sub
这是interpolation
2013-04-24 18:08
木吉他ll
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-24
收藏
得分:0 
回复 4楼 风吹过b
Private Sub Edit_Materialparatemer_Click()

   Form4.Show 1

   Dim cn As New ADODB.Connection
   Dim cmd As New
   Dim rs As ADODB.Recordset
   Dim i As Integer
   Dim nMaterial As Integer
   Dim Name As String

   i = 0
   nMaterial =
   Select Case nMaterial
          Case 0:
               Name = "C/SIC"
          Case 1:
               Name = "CH99"
          Case 2:
               Name = "UHTC-A"
   End Select
'///////////////////////////////////////////////////////////////////////////////////////数据库

   cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\material.mdb"          '链接数据库
   Set cmd.ActiveConnection = cn
    = adCmdUnknown
    = "select * from 材料属性 where 材料名='" & Name & "'"
   Set rs = cmd.Execute
   
   Do While Not rs.EOF
      With Parameter(i)
           .MOE = rs.Fields("弹性模量")
           .PR = rs.Fields("泊松比")
      End With
      rs.MoveNext
      i = i + 1
   Loop
   
End Sub
2013-04-24 18:19
木吉他ll
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-24
收藏
得分:0 
回复 4楼 风吹过b
以上是我写的函数,就是不知道哪里出错了
2013-04-24 18:20
木吉他ll
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-24
收藏
得分:0 
回复 4楼 风吹过b
Public Sub interpolation(Data() As Single, ByVal T As Single, ByRef Y As Single)

   Dim TT(10) As Integer                     '数据库里边的温度数组
   Dim h(9) As Single
   Dim u(1 To 9) As Single
   Dim λ(1 To 9) As Single
   Dim g(10) As Single
   Dim i As Integer
   Dim j As Integer
   Dim yy0 As Single                         '边界条件
   Dim yy10 As Single                        '边界条件
   Dim gmm As Single                         '中间变量
   Dim p As Single                           '中间变量
   Dim q As Single                           '中间变量
   Dim m(10) As Single                       '解空间
   Dim aa(0 To 10, 0 To 10) As Single        '系数矩阵

   yy0 = 0                                  '自然边界条件
   yy10 = 0

   TT(0) = 20
   TT(1) = 100
   TT(2) = 200
   TT(3) = 300
   TT(4) = 400
   TT(5) = 500
   TT(6) = 600
   TT(7) = 700
   TT(8) = 800
   TT(9) = 900
   TT(10) = 1000

   For i = 0 To 9 Step 1
       h(i) = TT(i + 1) - TT(i)
   Next i

   For i = 1 To 9 Step 1
       u(i) = h(i - 1) / (h(i - 1) + h(i))
   Next i

   For i = 1 To 9 Step 1
      λ(i) = h(i) / (h(i - 1) + h(i))
   Next i

   For i = 1 To 9
       gmm = (Data(i + 1) - Data(i)) / h(i) - (Data(i) - Data(i - 1)) / h(i - 1)
       g(i) = 6 * gmm / (h(i) + h(i - 1))
   Next i
   
   g(0) = 6 * ((Data(1) - Data(0)) / h(0) - yy0) / h(0)
   g(10) = 6 * (yy10 - (Data(10) - Data(9)) / h(9)) / h(9)
   
   For i = 0 To 10                     '系数矩阵清零
       For j = 0 To 10
           aa(i, j) = 0
       Next j
   Next i

   aa(0, 0) = 2                       '为系数矩阵赋值
   aa(0, 1) = 1

   For i = 1 To 9
       aa(i, i) = 2
       aa(i, i - 1) = u(i)
       aa(i, i + 1) = λ(i)
   Next i

   aa(10, 9) = 1
   aa(10, 10) = 2
   
   For i = 1 To 10                    '矩阵的对角化
       p = aa(i - 1, i - 1) / aa(i, i - 1)
       g(i) = g(i) * p - g(i - 1)
       For j = 0 To 10
           aa(i, j) = aa(i, j) * p - aa(i - 1, j)
       Next j
   Next i

   m(10) = g(10) / aa(10, 10)
   For i = 9 To 0 Step -1
       q = 0
       For j = 10 To i + 1 Step -1
           q = q + aa(i, j) * m(j)
       Next j
       m(i) = (g(i) - q) / aa(i, i)
   Next i

   For i = 0 To 9
       If T >= TT(i) And T <= TT(i + 1) Then
          Y = (m(i) * (TT(i + 1) - T) ^ 3) / (6 * h(i)) + (m(i + 1) * (T - TT(i)) ^ 3) / (6 * h(i)) + (Data(i) - (m(i) * h(i) ^ 2) / 6) * (TT(i + 1) - T) / h(i) + (Data(i + 1) - (m(i + 1) * h(i) ^ 2) / 6) * (T - TT(i)) / h(i)
       End If
   Next i

End Sub
这是interpolation  
我感觉没有错呀,为什么老有问题,谢谢指点  
2013-04-24 20:30
lowxiong
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:27
帖 子:652
专家分:3402
注 册:2008-5-7
收藏
得分:5 
过程interpolation第一个参数是浮点类型的数组,而你传进去的是一个浮点类型的单个变量(Param(10).MOE是一个属于Param数组中的单个浮点变量),当然提示类型不匹配了。
2013-04-24 20:48
木吉他ll
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-24
收藏
得分:0 
回复 9楼 lowxiong
那应该怎样写呀,难道要写成 Call interpolation(Parameter().MOE, TAverage, E),我也试过,还是有错误弹出
2013-04-24 21:02
快速回复:调用子工程时,一个实参是自定义机构数组,为什么调用老出错呢?
数据加载中...
 
   



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

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