求助一个关于替换的问题..
本帖最后由 傻娃 于 2009-6-24 18:11 编辑p=0
q=1
r=2
s=3
t=4
u=5
v=6
w=7
x=8
y=9
m=-
请问下..
如果我想要在一个$input1里打上vtsyx然后点击一下按钮就可以在$input2里转换成64398?
例子:
xwsq=8731
yrvwpw=926707
是根据上面的英文去对应数字....
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 333, 100, 330, 235)
$Input1 = GUICtrlCreateInput("这里输入英文", 16, 24, 121, 21)
$Button1 = GUICtrlCreateButton("转换", 152, 24, 75, 25, $WS_GROUP)
$Input2 = GUICtrlCreateInput("这里显示转换后的数字", 168, 56, 137, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd 1# 傻娃
通过读配置文件来实现吧! 你的那段文字是通过什么获取的?才好下一步,用楼上的方法是最省事的
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 333, 100, 330, 235)
$Input1 = GUICtrlCreateInput("这里输入英文", 16, 24, 121, 21)
$Button1 = GUICtrlCreateButton("转换", 152, 24, 75, 25, $WS_GROUP)
$Input2 = GUICtrlCreateInput("这里显示转换后的数字", 168, 56, 137, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Str = ''
While 1
Sleep(90)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If StringStripWS(GUICtrlRead($Input1), 8) = '' Then ContinueLoop
For $I = 1 To StringLen(GUICtrlRead($Input1))
Switch StringMid(GUICtrlRead($Input1), $I, 1)
Case 'p'
$Str &= 0
Case 'q'
$Str &= 1
Case 'r'
$Str &= 2
Case 's'
$Str &= 3
Case 't'
$Str &= 4
Case 'u'
$Str &= 5
Case 'v'
$Str &= 6
Case 'w'
$Str &= 7
Case 'x'
$Str &= 8
Case 'y'
$Str &= 9
Case 'm'
$Str &= '-'
EndSwitch
Next
GUICtrlSetData($Input2, $Str)
EndSwitch
WEnd
不好意思 ,没仔细看贴,楼主是要获取Input的内容,楼上已给出答案,我也给出一份答卷
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 333, 100, 330, 235)
$Input1 = GUICtrlCreateInput("这里输入英文", 16, 24, 121, 21)
$Button1 = GUICtrlCreateButton("转换", 152, 24, 75, 25, $WS_GROUP)
$Input2 = GUICtrlCreateInput("这里显示转换后的数字", 168, 56, 137, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Str = ''
While 1
Sleep(90)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$Str=StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(GUICtrlRead($Input1),"p","0"), _
"q","1"),"r","2"),"s","3"),"t","4"),"u","5"),"v","6"),"w","7"),"x","8"),"y","9"),"m","-")
GUICtrlSetData($Input2, $Str)
EndSwitch
WEnd
页:
[1]