我輸入資料運行程式時,程式提示上面這個錯誤,通過查找找到
a2 = W12(3) * w1 + W12(4) * w2 + W12(5) * w3 + B1(1)
這是我的一個中間式子,里面都是陣列和變數,發現我輸的資料得出f值剛好是0,而VB說它是空值
具體代碼如下
Private Sub Command1_Click()
Dim W12() '定義陣列
W12 = Array(-0.12634521001675, -4.6694806914686, 0.42026116123439, 5.10867971591759, 1.51942107882065, -0.42243980916051, -1.66877957850959, -0.20468373820466, 0.3572928557475, 0.03610001145893, 4.53787321728016, -0.50977927762321)
Dim W23()
W23 = Array(-5.89468238932569, 0.11644047624008, -3.94832907664878, -1.76229980989318)
Dim B1()
B1 = Array(-5.96780654305263, -2.33430134475403, -0.773411222728292, 3.4661792485999)
Const B2 As Double = 3.21772616222852
Dim w1 As Single, w2 As Single, w3 As Single '定義變數 w1 w2 w3
Let w1 = Val(Text1.Text) '獲取輸入傳感器測量值
Let w2 = Val(Text2.Text) '獲取比值
Let w3 = Val(Text3.Text) '獲取濃度
Dim a1 As Variant, a2 As Variant, a3 As Variant, a4 As Variant, a11 As Variant, a12 As Variant, a13 As Variant, a14 As Variant '定義變數
a1 = W12(0) * w1 + W12(1) * w2 + W12(2) * w3 + B1(0) '
a2 = W12(3) * w1 + W12(4) * w2 + W12(5) * w3 + B1(1)
a3 = W12(6) * w1 + W12(7) * w2 + W12(8) * w3 + B1(2)
a4 = W12(9) * w1 + W12(10) * w2 + W12(11) * w3 + B1(3)
'a5 = W12(12) * w1 + W12(13) * w2 + W12(14) * w3 + B1(4) '
a11 = W23(0) * 1 / (1 + e ^ (-a1)) '
a12 = W23(1) * 1 / (1 + e ^ (-a2)) '
a13 = W23(2) * 1 / (1 + e ^ (-a3))
a14 = W23(3) * 1 / (1 + e ^ (-a4)) '
'%a15 = W23(4)*logsig(a5)';%輸出層到隱層
a = a11 + a12 + a13 + a14 + B2 ';%匯總起來
'w4 = a '(a) ' %輸出含水率值
Text4.Text = a
End Sub
uj5u.com熱心網友回復:
計算公式要加保護,比如,a2 =val( W12(3) * w1) +val( W12(4) * w2 )+ val(W12(5) * w3) +val( B1(1) ),當然可以每個變數加valuj5u.com熱心網友回復:
謝謝,我這就回去除錯一下轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/20047.html
標籤:VB基礎類
上一篇:急!!!求幫看下這串代碼
