一段代码看的很糊涂,谁能给讲讲?
For j = 1 To 6: vDenominator(j) = 0: Nextmsg$ = FY + "MDSScores.csv"
Open (fPath$ + "P4P\" + FY + "MDSscores.csv") For Input As #1
For j = 1 To 7: Input #1, xx$: Next
While Not EOF(1)
Input #1, xx$: For j = 1 To 6: Input #1, L$(j): Next
PIN(0, 1) = Val(xx$)
For i = 1 To nHomes
If PIN(0, 1) = PIN(i, 1) Or PIN(0, 1) = PIN(i, 2) Then Exit For
Next
For j = 1 To 6
If L$(j) <> "" Then MDS(i, j) = 100 - Val(L$(j))
If NHStatus(i) = 1 Then 'If elgibile, include in average calculation
MDS(nHomesA, j) = MDS(nHomesA, j) + MDS(i, j) * TotDays(i)
If MDS(i, j) > 0 Then vDenominator(j) = vDenominator(j) + TotDays(i)
If MDS(i, j) > vMax(j + 9) Then vMax(j + 9) = MDS(i, j)
End If
Next
Wend
特别是这几句IF语句,看不懂逻辑关系
For j = 1 To 6
If L$(j) <> "" Then MDS(i, j) = 100 - Val(L$(j))
If NHStatus(i) = 1 Then 'If elgibile, include in average calculation
MDS(nHomesA, j) = MDS(nHomesA, j) + MDS(i, j) * TotDays(i)
If MDS(i, j) > 0 Then vDenominator(j) = vDenominator(j) + TotDays(i)
If MDS(i, j) > vMax(j + 9) Then vMax(j + 9) = MDS(i, j)
L(2)这一列有几个空值,那这几个空值对应的MDS(i,2)是多少呢?
这个MDS(I,J)求不对,最后的MDS(nHomesA, j) 和 vDenominator(j) 都不知道呀。
算出来的值和我在EXCEL上算得不同 --------------------编程问答-------------------- 嘛子东东,我先帮楼主整理下代码吧.
自已看看,或许会更明白
For j = 1 To 6: vDenominator(j) = 0: Next--------------------编程问答-------------------- 代码里面不完整,有一些变量状态未知.......... --------------------编程问答-------------------- 我想问的是在这些IF中,县执行哪个IF呢?
msg$ = FY + "MDSScores.csv"
Open (fPath$ + "P4P\" + FY + "MDSscores.csv") For Input As #1
For j = 1 To 7: Input #1, xx$: Next
While Not EOF(1)
Input #1, xx$
PIN(0, 1) = Val(xx$)
For i = 1 To nHomes
If PIN(0, 1) = PIN(i, 1) Or PIN(0, 1) = PIN(i, 2) Then Exit For
Next
For j = 1 To 6: Input #1, L$(j): Next
For j = 1 To 6
If L$(j) <> "" Then MDS(i, j) = 100 - Val(L$(j))
If NHStatus(i) = 1 Then 'If elgibile, include in average calculation
MDS(nHomesA, j) = MDS(nHomesA, j) + MDS(i, j) * TotDays(i)
If MDS(i, j) > 0 Then vDenominator(j) = vDenominator(j) + TotDays(i)
If MDS(i, j) > vMax(j + 9) Then vMax(j + 9) = MDS(i, j)
End If
Next
Wend
If L$(j) <> "" Then MDS(i, j) = 100 - Val(L$(j))
If NHStatus(i) = 1 Then 'If elgibile, include in average calculation
MDS(nHomesA, j) = MDS(nHomesA, j) + MDS(i, j) * TotDays(i)
If MDS(i, j) > 0 Then vDenominator(j) = vDenominator(j) + TotDays(i)
If MDS(i, j) > vMax(j + 9) Then vMax(j + 9) = MDS(i, j)
还有L$(2)这一列有几个空值,那这几个空值对应的MDS(i,2)是多少呢? --------------------编程问答-------------------- 这也不能怪楼主, 这代码的风格, 要拉出去枪毙7,8次才够 --------------------编程问答-------------------- If L$(j) <> "" Then MDS(i, j) = 100 - Val(L$(j))
当L$(J)里有空值,MDS(I,J)是什么呢? --------------------编程问答-------------------- 没人回答?
补充:VB , 基础类