[已解决]請教 連續數據的修改 該怎樣 簡短?
本帖最后由 tcpuuu 于 2012-2-22 15:42 编辑;GUICtrlSetData($A1,GUICtrlRead($A2));抓數據到$A2
;GUICtrlSetData($A2,GUICtrlRead($A3));抓數據到$A2
;GUICtrlSetData($A3,GUICtrlRead($A4));抓數據到$A2
;GUICtrlSetData($A4,GUICtrlRead($A5));抓數據到$A2
;GUICtrlSetData($A5,GUICtrlRead($A6));抓數據到$A2
;GUICtrlSetData($A6,GUICtrlRead($A7));抓數據到$A2
;GUICtrlSetData($A7,GUICtrlRead($A8));抓數據到$A2
;GUICtrlSetData($A8,GUICtrlRead($A9));抓數據到$A2
;GUICtrlSetData($A9,GUICtrlRead($A10));抓數據到$A2
;GUICtrlSetData($A10,GUICtrlRead($A11));抓數據到$A2
;GUICtrlSetData($A11,GUICtrlRead($A12));抓數據到$A2
;GUICtrlSetData($A12,GUICtrlRead($A13));抓數據到$A2
;GUICtrlSetData($A13,GUICtrlRead($A14));抓數據到$A2
;GUICtrlSetData($A14,GUICtrlRead($A15));抓數據到$A2
;GUICtrlSetData($A15,GUICtrlRead($A16));抓數據到$A2
;GUICtrlSetData($A16,GUICtrlRead($A17));抓數據到$A2
;GUICtrlSetData($A17,GUICtrlRead($A18));抓數據到$A2
;GUICtrlSetData($A18,GUICtrlRead($A19));抓數據到$A2
For $i = $A1 to $A18
For $J = $A2 to $A19
GUICtrlSetData($i,$J)
Next
Next
=========================================
1改成22改成399改成100 本帖最后由 半芯竹 于 2012-2-11 00:47 编辑
local $a
for $i=1 to 18
GUICtrlSetData($a[$i],GUICtrlRead($a[$i+1]))
next
本帖最后由 tcpuuu 于 2012-2-11 03:46 编辑
好像不行?
www 應該往上 跑1格
最後18改成 19的數值GUICreate('ABC',200,430,-1,-1)
Global $A1 = GUICtrlCreateLabel ("",2, 45,42,16,0x00800000,0x01)
Global $A2 = GUICtrlCreateLabel ("",2, 63,42,16,0x00800000,0x01)
Global $A3 = GUICtrlCreateLabel ("",2, 81,42,16,0x00800000,0x01)
Global $A4 = GUICtrlCreateLabel ("",2, 99,42,16,0x00800000,0x01)
Global $A5 = GUICtrlCreateLabel ("",2, 117,42,16,0x00800000,0x01)
Global $A6 = GUICtrlCreateLabel ("",2, 135,42,16,0x00800000,0x01)
Global $A7 = GUICtrlCreateLabel ("",2, 153,42,16,0x00800000,0x01)
Global $A8 = GUICtrlCreateLabel ("",2, 171,42,16,0x00800000,0x01)
Global $A9 = GUICtrlCreateLabel ("",2, 189,42,16,0x00800000,0x01)
Global $A10 = GUICtrlCreateLabel("",2, 207,42,16,0x00800000,0x01)
Global $A11 = GUICtrlCreateLabel("",2, 225,42,16,0x00800000,0x01)
Global $A12 = GUICtrlCreateLabel("",2, 243,42,16,0x00800000,0x01)
Global $A13 = GUICtrlCreateLabel("",2, 261,42,16,0x00800000,0x01)
Global $A14 = GUICtrlCreateLabel("",2, 279,42,16,0x00800000,0x01)
Global $A15 = GUICtrlCreateLabel("",2, 297,42,16,0x00800000,0x01)
Global $A16 = GUICtrlCreateLabel("",2, 315,42,16,0x00800000,0x01)
Global $A17 = GUICtrlCreateLabel("",2, 333,42,16,0x00800000,0x01)
Global $A18 = GUICtrlCreateLabel("",2, 351,42,16,0x00800000,0x01)
Global $A19 = GUICtrlCreateLabel("WWW",2, 369,42,16,0x00800000,0x01)
local $a
for $i=1 to 18
GUICtrlSetData($a[$i],GUICtrlRead($a[$i+1]))
next
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3 本帖最后由 半芯竹 于 2012-2-11 12:15 编辑
回复 3# tcpuuu
你的问题,总是要人说得很清楚,一定要人帮你写好,你才满意……
明明都$a数组了。你还GLOBAL个P啊。。。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate('ABC',200,430,-1,-1)
local $A
$A = GUICtrlCreateLabel ("",2, 45,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("你大爷",2, 63,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 81,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 99,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 117,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 135,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 153,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 171,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel ("",2, 189,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 207,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 225,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 243,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 261,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 279,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 297,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 315,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 333,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("",2, 351,42,16,0x00800000,0x01)
$A = GUICtrlCreateLabel("WWW",2, 369,42,16,0x00800000,0x01)
GUISetState()
for $i=1 to 18
GUICtrlSetData($a[$i],GUICtrlRead($a[$i+1]))
next
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
以下是精简的。你自己看着办吧。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
local $A,$b=45
GUICreate('ABC',200,430,-1,-1)
For $i = 1 To 19
$A[$i] = GUICtrlCreateLabel ("",2, $b,42,16,0x00800000,0x01)
$b+=18
If $i= 3 Then GUICtrlSetData($a[$i],'你大爷啊')
If $i =10 Then GUICtrlSetData($a[$i],'你大娘啊')
If $i= 19 ThenGUICtrlSetData($a[$i],'www')
Next
GUISetState()
for $i=1 to 18
GUICtrlSetData($a[$i],GUICtrlRead($a[$i+1]))
next
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd 本帖最后由 tcpuuu 于 2012-2-11 15:27 编辑
嗯 感謝!本篇值得收藏要編有眾多格的(要幾格有幾格) 極為方便 整整齊齊
我的問題已解決
在問1下 底下這個是 獲得$a1的數據
GUICtrlRead($a1)
如果要 獲得$a1 的背景顏色要用 那個函數 回复 5# tcpuuu
背景色可不是那么容易获取的。
改变下思路吧,你这都是自己创建的控件,自己设置的颜色,完全可以都储存在一个数组变量里面,用的时候直接取,有变更时先变更到数组。哪用得着每次都要 GUICtrlRead() 之类的。 感謝 AFAN 版主解說說真的 我實是看不懂(只會拿現成的 修改)
上面是要實現所有數值往上移希望連背景顏色也往上移
GUICtrlSetBkColor($A1,"跟$A2的背景顏色一樣")
修改$A1的顏色 跟$A2的背景顏色一樣沒有這種函數嗎? 回复 7# tcpuuu
都做成函数,还用你自己写什么?一个个搭就完了 回复 7# tcpuuu
要学会变通啊~#include <Array.au3>
Local $iX = 19
Local $aBL_V[$iX], $aBL_C[$iX], $aBL_i[$iX]
Local $_L = 2, $_T = 23, $_YJ = 18, $_W = 42, $_H = 16
GUICreate('ABC', 200, 430)
For $i = 0 To $iX - 1
$aBL_V[$i] = Random(1, 1000, 1)
$aBL_i[$i] = GUICtrlCreateLabel($aBL_V[$i], $_L, $_T + $_YJ * $i, $_W, $_H, 0x00800000, 0x01)
$aBL_C[$i] = Random(0, 0xFFFFFF, 1)
GUICtrlSetBkColor(-1, $aBL_C[$i])
Next
$iBT = GUICtrlCreateButton('添加新值并上移', 70, 200, 100, 20)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $iBT
_Add()
EndSwitch
WEnd
Func _Add()
_ArrayPush($aBL_V, Random(1, 1000, 1))
_ArrayPush($aBL_C, Random(0, 0xFFFFFF, 1))
For $i = 0 To $iX - 1
GUICtrlSetData($aBL_i[$i], $aBL_V[$i])
GUICtrlSetBkColor($aBL_i[$i], $aBL_C[$i])
Next
EndFunc ;==>_Add
本帖最后由 tcpuuu 于 2012-2-11 20:17 编辑
afan 超級版主您好太複雜我看不懂
還是非常感謝你
可以弄個 我看懂的嗎?
這是因為要在底下輸入數據時 先要將所有數往上移 空出位置來輸入 (輸入以後如果怎樣怎樣就變紅色)
GUICreate("EXCEL TEST",180,600, -1, -1)
local $A,$AUP=20
For $i = 1 To 30
$A[$i] = GUICtrlCreateInput("",2,$AUP,42,16)
$AUP+=17
Next
for $i=1 to 29
GUICtrlSetData($A[$i],-3+($A[$i+1]))
next
GUICtrlSetBkColor($A,0xFF0000)
GUICtrlSetBkColor($A,0xFF0000)
$1But = GUICtrlCreateButton('添加新值并上移', 70, 200, 100, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $1But
for $i=1 to 29
GUICtrlSetData($A[$i],GUICtrlRead($A[$i+1]));每個數值往上移
next
;=============================
;連顏色也往上移
;================================
EndSwitch #include <Array.au3>
Local $iX = 20 ;左侧队列数量
Local $aBL_V[$iX], $aBL_C[$iX], $aBL_i[$iX]
Local $_L = 2, $_T = 23, $_YJ = 18, $_W = 42, $_H = 16
GUICreate('ABC', 200, 430)
For $i = 0 To $iX - 1
$aBL_V[$i] = Random(1, 100, 1) ;1~100随机数,可以自己设置具体值
$aBL_i[$i] = GUICtrlCreateLabel($aBL_V[$i], $_L, $_T + $_YJ * $i, $_W, $_H, 0x00800000, 0x01)
$aBL_C[$i] = 0xFFFFFF
If $aBL_V[$i] > 80 Then $aBL_C[$i] = 0xFF0000 ;假定数值 > 80 则为红色
GUICtrlSetBkColor(-1, $aBL_C[$i])
Next
$iInp = GUICtrlCreateInput('', 70, 175, 100, 20)
$iBT = GUICtrlCreateButton('添加新值并上移', 70, 200, 100, 20)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $iBT, $iInp ;点击按钮或在输入框回车即可添加
_Add(Number(GuiCtrlRead($iInp)))
EndSwitch
WEnd
Func _Add($val)
_ArrayPush($aBL_V, $val)
Local $C = 0xFFFFFF
If $val > 80 Then $C = 0xFF0000 ;假定数值 > 80 则为红色
_ArrayPush($aBL_C, $C)
For $i = 0 To $iX - 1
GUICtrlSetData($aBL_i[$i], $aBL_V[$i])
GUICtrlSetBkColor($aBL_i[$i], $aBL_C[$i])
Next
EndFunc ;==>_Add
页:
[1]