看似简单的操作产生狂野疯狂的结果 [英] Seemingly simple operation producing Wildly Crazy results

查看:55
本文介绍了看似简单的操作产生狂野疯狂的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,一个大学课程只有24名学生,但是代码后面的

表示零As,20 Bs,16 Cs,4 Ds和8 Fs。当

它打印出来然后说0 As,40 Bs,32 Cs,8 Ds和16 Fs。应该显示的实际

数是零As,10 Bs,8 Cs,2 Ds和4 Fs。我找不到

代码有什么问题。这是:


选项比较数据库

选项明确


''全局变量

Dim numOfA As Integer

Dim numOfB As Integer

Dim numOfC As Integer

Dim numOfD As Integer

Dim numOfF As Integer


私人子报告_打开(取消为整数)

numOfA = 0

numOfB = 0
numOfC = 0

numOfD = 0

numOfF = 0

结束子


Private Sub GroupHeader1_Format(取消为整数,FormatCount为整数)

如果txtAvg> = 0.92那么

numOfA = numOfA + 1

结束如果


如果txtAvg> = 0.82并且txtAvg< 0.92然后

numOfB = numOfB + 1

结束如果


如果txtAvg> = 0.72并且txtAvg< 0.82然后

numOfC = numOfC + 1

结束如果


如果txtAvg> = 0.62并且txtAvg< 0.72然后

numOfD = numOfD + 1

结束如果


如果txtAvg< 0.62然后

numOfF = numOfF + 1

结束如果

结束子



私函数getAay()作为整数

getAay = numOfA

结束函数


私函数getBee()As Integer

getBee = numOfB

结束函数


私函数getCee()作为整数

getCee = numOfC

结束函数

私函数getDee()作为整数

getDee = numOfD

结束函数


私函数getEff()为整数

getEff = numOfF

结束函数

For example, one college course has only 24 students in it, but the
following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs. When
it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and 16 Fs. The actual
number it should show is zero As, 10 Bs, 8 Cs, 2 Ds, and 4 Fs. I can''t find
anything wrong with the code. Here it is:

Option Compare Database
Option Explicit

''global variables
Dim numOfA As Integer
Dim numOfB As Integer
Dim numOfC As Integer
Dim numOfD As Integer
Dim numOfF As Integer

Private Sub Report_Open(Cancel As Integer)
numOfA = 0
numOfB = 0
numOfC = 0
numOfD = 0
numOfF = 0
End Sub

Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
If txtAvg >= 0.92 Then
numOfA = numOfA + 1
End If

If txtAvg >= 0.82 And txtAvg < 0.92 Then
numOfB = numOfB + 1
End If

If txtAvg >= 0.72 And txtAvg < 0.82 Then
numOfC = numOfC + 1
End If

If txtAvg >= 0.62 And txtAvg < 0.72 Then
numOfD = numOfD + 1
End If

If txtAvg < 0.62 Then
numOfF = numOfF + 1
End If
End Sub


Private Function getAay() As Integer
getAay = numOfA
End Function

Private Function getBee() As Integer
getBee = numOfB
End Function

Private Function getCee() As Integer
getCee = numOfC
End Function
Private Function getDee() As Integer
getDee = numOfD
End Function

Private Function getEff() As Integer
getEff = numOfF
End Function

推荐答案

Richard Hollenbeck< ri **************** @ verizon.net>写道:

:例如,一个大学课程只有24名学生,但

:以下代码表示零As,20 Bs,16 Cs,4 Ds和8 Fs。

:当它打印出来然后说0 As,40 Bs,32 Cs,8 Ds和16 Fs。

:它应该显示的实际数字是零As,10 Bs,8 Cs,2 Ds和4 Fs。

:我找不到任何问题代码。这是:



:期权比较数据库

:期权明确



:''全局变量

:Dim numOfA As Integer

:Dim numOfB As Integer

:Dim numOfC As Integer

:Dim numOfD As Integer

:Dim numOfF As Integer



:Private Sub Report_Open(取消为整数)

:numOfA = 0

:numOfB = 0

:numOfC = 0

:numOfD = 0
:numOfF = 0

:End Sub



:Private Sub GroupHeader1_Format(取消为整数,FormatCount为

:整数)如果txtAvg> = 0.92那么

:numOfA = numOfA + 1

:结束如果



:如果txtAvg> = 0.82并且txtAvg< 0.92然后

:numOfB = numOfB + 1

:结束如果



:如果txtAvg> = 0.72和txtAvg< 0.82然后

:numOfC = numOfC + 1

:结束如果



:如果txtAvg> = 0.62和txtAvg< 0.72然后

:numOfD = numOfD + 1

:结束如果



:如果txtAvg< 0.62然后

:numOfF = numOfF + 1

:结束如果

:结束Sub





< snip>


所以它将正确的答案乘以2?我想知道......这个标题事件会触发多少

次?

-

如果回复,请删除under_scores邮件。
Richard Hollenbeck <ri****************@verizon.net> wrote:
: For example, one college course has only 24 students in it, but the
: following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs.
: When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and 16 Fs. The
: actual number it should show is zero As, 10 Bs, 8 Cs, 2 Ds, and 4 Fs.
: I can''t find anything wrong with the code. Here it is:
:
: Option Compare Database
: Option Explicit
:
: ''global variables
: Dim numOfA As Integer
: Dim numOfB As Integer
: Dim numOfC As Integer
: Dim numOfD As Integer
: Dim numOfF As Integer
:
: Private Sub Report_Open(Cancel As Integer)
: numOfA = 0
: numOfB = 0
: numOfC = 0
: numOfD = 0
: numOfF = 0
: End Sub
:
: Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As
: Integer) If txtAvg >= 0.92 Then
: numOfA = numOfA + 1
: End If
:
: If txtAvg >= 0.82 And txtAvg < 0.92 Then
: numOfB = numOfB + 1
: End If
:
: If txtAvg >= 0.72 And txtAvg < 0.82 Then
: numOfC = numOfC + 1
: End If
:
: If txtAvg >= 0.62 And txtAvg < 0.72 Then
: numOfD = numOfD + 1
: End If
:
: If txtAvg < 0.62 Then
: numOfF = numOfF + 1
: End If
: End Sub
:
:
<snip>

So it''s multiplying the correct answers by two? I wonder...how many
times does the format event fire for this header?
--
Please remove the under_scores if replying by mail.


是的,它最初将它乘以2,但是,当我打印报告时,

再次乘以2 。


" Roald Oines" < R _ ******* @ bresnan.net>在消息中写道

新闻:我们******************** @ bresnan.com ...
Yes it''s multiplying it by 2 initially, but then, when I print the report,
it multiplies by two again.

"Roald Oines" <r_*******@bresnan.net> wrote in message
news:Us********************@bresnan.com...
理查德Hollenbeck< ri **************** @ verizon.net>写道:
:例如,一个大学课程只有24名学生,但
:以下代码说有零As,20 Bs,16 Cs,4 Ds和8 Fs。 />:当它打印时,然后说0 As,40 Bs,32 Cs,8 Ds和16 Fs。
:它应该显示的实际数字是零As,10 Bs,8 Cs,2 Ds和4 Fs。
:我发现代码没有任何问题。这是:

:选项比较数据库
:选项明确

:''全局变量
:Dim numOfA As Integer
:Dim numOfB As Integer
:Dim numOfC As Integer
:Dim numOfD As Integer
:Dim numOfF As Integer

:Private Sub Report_Open(Cancel As Integer )
:numOfA = 0
:numOfB = 0
:numOfC = 0
:numOfD = 0
:numOfF = 0
:End Sub

:Private Sub GroupHeader1_Format(取消为整数,FormatCount为
:整数)如果txtAvg> = 0.92那么
:numOfA = numOfA + 1
:结束如果

:如果txtAvg> = 0.82并且txtAvg< 0.92然后
:numOfB = numOfB + 1
:结束如果

:如果txtAvg> = 0.72并且txtAvg< 0.82然后
:numOfC = numOfC + 1
:结束如果

:如果txtAvg> = 0.62并且txtAvg< 0.72然后
:numOfD = numOfD + 1
:结束如果

:如果txtAvg< 0.62然后
:numOfF = numOfF + 1
:结束如果
:结束子


< snip>

-
如果通过邮件回复,请删除under_scores。
Richard Hollenbeck <ri****************@verizon.net> wrote:
: For example, one college course has only 24 students in it, but the
: following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs.
: When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and 16 Fs. The
: actual number it should show is zero As, 10 Bs, 8 Cs, 2 Ds, and 4 Fs.
: I can''t find anything wrong with the code. Here it is:
:
: Option Compare Database
: Option Explicit
:
: ''global variables
: Dim numOfA As Integer
: Dim numOfB As Integer
: Dim numOfC As Integer
: Dim numOfD As Integer
: Dim numOfF As Integer
:
: Private Sub Report_Open(Cancel As Integer)
: numOfA = 0
: numOfB = 0
: numOfC = 0
: numOfD = 0
: numOfF = 0
: End Sub
:
: Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As
: Integer) If txtAvg >= 0.92 Then
: numOfA = numOfA + 1
: End If
:
: If txtAvg >= 0.82 And txtAvg < 0.92 Then
: numOfB = numOfB + 1
: End If
:
: If txtAvg >= 0.72 And txtAvg < 0.82 Then
: numOfC = numOfC + 1
: End If
:
: If txtAvg >= 0.62 And txtAvg < 0.72 Then
: numOfD = numOfD + 1
: End If
:
: If txtAvg < 0.62 Then
: numOfF = numOfF + 1
: End If
: End Sub
:
:
<snip>

So it''s multiplying the correct answers by two? I wonder...how many
times does the format event fire for this header?
--
Please remove the under_scores if replying by mail.



Richard Hollenbeck< ri **************** @ verizon.net>写道:

:是的,它最初将它乘以2,但是当我打印

:报告时,它再次乘以2。



:Roald Oines < R _ ******* @ bresnan.net>在消息中写道

:新闻:我们******************** @ bresnan.com ...

:: Richard Hollenbeck< ri **************** @ verizon.net>写道:

:::例如,一个大学课程只有24名学生,但

:::下面的代码说有零As,20 Bs, 16 Cs,4 Ds和8 Fs。

:::当它打印出来然后说0 As,40 Bs,32 Cs,8 Ds和16 Fs。

:::它应该显示的实际数字是零As,10 Bs,8 Cs,2 Ds和

::: 4 Fs。我发现代码没有任何问题。这是:

:::

:::选项比较数据库

:::选项明确

:::

:::''全局变量

::: Dim numOfA As Integer

::: Dim numOfB As Integer

::: Dim numOfC As Integer

::: Dim numOfD As Integer

::: Dim numOfF As Integer

:::

:::私有子报告_打开(取消为整数)

::: numOfA = 0

::: numOfB = 0

::: numOfC = 0

::: numOfD = 0

::: numOfF = 0

::: End Sub

:::

::: Private Sub GroupHeader1_Format(取消为整数,FormatCount为

::: Integer )如果txtAvg> = 0.92那么

::: numOfA = numOfA + 1

:::结束如果

:::

:::如果txtAvg> = 0.82并且txtAvg< 0.92然后

::: numOfB = numOfB + 1

:::结束如果

:::

:::如果txtAvg> = 0.72并且txtAvg< 0.82然后

::: numOfC = numOfC + 1

:::结束如果

:::

:::如果txtAvg> = 0.62并且txtAvg< 0.72然后

::: numOfD = numOfD + 1

:::结束如果

:::

:::如果txtAvg< 0.62然后

::: numOfF = numOfF + 1

:::结束如果

::: End Sub

:::

:::

::< snip>

::

::所以它正确的答案乘以2?我想知道......这个标题的格式事件触发多少

:: times?


我的观点是格式事件可以触发超过一旦Access有

返回前面的部分进行多次格式化传递。这将

导致你的计数每次增加。您可以使用Retreat事件

撤消您在

部分中只需要完成的任何更改。


-

如果通过邮件回复,请删除under_scores。
Richard Hollenbeck <ri****************@verizon.net> wrote:
: Yes it''s multiplying it by 2 initially, but then, when I print the
: report, it multiplies by two again.
:
: "Roald Oines" <r_*******@bresnan.net> wrote in message
: news:Us********************@bresnan.com...
:: Richard Hollenbeck <ri****************@verizon.net> wrote:
::: For example, one college course has only 24 students in it, but the
::: following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs.
::: When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and 16 Fs.
::: The actual number it should show is zero As, 10 Bs, 8 Cs, 2 Ds, and
::: 4 Fs. I can''t find anything wrong with the code. Here it is:
:::
::: Option Compare Database
::: Option Explicit
:::
::: ''global variables
::: Dim numOfA As Integer
::: Dim numOfB As Integer
::: Dim numOfC As Integer
::: Dim numOfD As Integer
::: Dim numOfF As Integer
:::
::: Private Sub Report_Open(Cancel As Integer)
::: numOfA = 0
::: numOfB = 0
::: numOfC = 0
::: numOfD = 0
::: numOfF = 0
::: End Sub
:::
::: Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As
::: Integer) If txtAvg >= 0.92 Then
::: numOfA = numOfA + 1
::: End If
:::
::: If txtAvg >= 0.82 And txtAvg < 0.92 Then
::: numOfB = numOfB + 1
::: End If
:::
::: If txtAvg >= 0.72 And txtAvg < 0.82 Then
::: numOfC = numOfC + 1
::: End If
:::
::: If txtAvg >= 0.62 And txtAvg < 0.72 Then
::: numOfD = numOfD + 1
::: End If
:::
::: If txtAvg < 0.62 Then
::: numOfF = numOfF + 1
::: End If
::: End Sub
:::
:::
:: <snip>
::
:: So it''s multiplying the correct answers by two? I wonder...how many
:: times does the format event fire for this header?

My point is that the format event can fire more than once if Access has
to return to previous sections for multiple formatting passes. This will
cause your counts to increment each time. You can use the Retreat event
to undo any changes you''ve done that you only want done once in the
section.

--
Please remove the under_scores if replying by mail.


这篇关于看似简单的操作产生狂野疯狂的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆