找回密码
 加入
搜索
查看: 1015|回复: 4

求助一个关于替换的问题..

[复制链接]
发表于 2009-6-24 00:48:55 | 显示全部楼层 |阅读模式
本帖最后由 傻娃 于 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
发表于 2009-6-24 10:43:21 | 显示全部楼层
1# 傻娃

通过读配置文件来实现吧!
发表于 2009-6-24 11:22:39 | 显示全部楼层
你的那段文字是通过什么获取的?才好下一步,用楼上的方法是最省事的
发表于 2009-6-24 12:02:02 | 显示全部楼层

#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 
发表于 2009-6-24 12:11:29 | 显示全部楼层
不好意思 ,没仔细看贴,楼主是要获取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 
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-10 10:55 , Processed in 0.075096 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表