Pic1为picturebox控件名
在picturebox控件上显示I 值。并根据判断条件改变显示I值的颜色,语句如下,为何只显示循环判断到的最后一个值为红色。比如m_Array(1)=3 ,m_Array(4)=6,m_Array(20)=28.本想将3,6和28显示成红色,结果却只显示28为红色。如果将 if语句中的颜色显示语句改成字体显示(如改成注释中的语句)却又可以将3,6和28都显示成粗体。因需要用改变颜色来显示,急待解决。  dim m_array(j)       'j<29
dim I as integer
for i = 1 to 30 
  for j = 1 to 29
if i = m_array(j) 
    pic1. ForeColor = &HFF&      '红色
    'pic1.Font.Bold=True
else
    pic1.ForeColor= &H80000012   '黑色
    'pic1.Font.Bold=False
end if
next j
next i

解决方案 »

  1.   

    dim m_array(j)       'j<29
    dim I as integer
    for i = 1 to 30 
      for j = 1 to 29
        if i = m_array(j) 
           pic1. ForeColor = &HFF&      '红色
           'pic1.Font.Bold=True
           exit for'  注意这里
        end if    if j>29 then‘没有发现匹配的
           pic1.ForeColor= &H80000012   '黑色
          'pic1.Font.Bold=False
        end if
      next j
    next i
      

  2.   

    不好意思,应改成这样。(在程序方面)dim m_array(j)       'j<29
    dim I as integer
    for i = 1 to 30 
      for j = 1 to 29
        if i = m_array(j) 
           pic1. ForeColor = &HFF&      '红色
           'pic1.Font.Bold=True
           exit for'  注意这里
        end if
      next j  if j>29 then‘没有发现匹配的
          pic1.ForeColor= &H80000012   '黑色
          'pic1.Font.Bold=False
       end if
    next i
      

  3.   

    按lazycat818的方法是可以,谢谢!同时又带出个新问题,就是在每次刷新的时候画面会明显刷新两次,两次间隔时间较长,如果多刷新几次,就更乱了。