ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


2 posters

    ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ

    avatar
    darkbeeza10
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ Empty ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ Empty
    จำนวนข้อความ : 11
    ความนิยม : 4
    เข้าร่วมเมื่อ : 26/07/2013

    ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ Empty ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ

    ตั้งหัวข้อ by darkbeeza10 03/06/14, 10:39 pm

    คือว่า ผมอยากให้เราใส่ข้อความนึง แล้วให้มันแสดงอีกข้อความอ่าครับ
    อย่างเช่น input1=ant input2=มด input1=bee input2=ผึ้ง
    อะไรประมาณนี้อ่าครับ ช่วยหน่อยน่ะครับ
    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 235, 85, 405, 257)
    $Input1 = GUICtrlCreateInput("", 16, 8, 121, 21)
    $Button1 = GUICtrlCreateButton("Button1", 144, 8, 75, 25)
    $Input2 = GUICtrlCreateInput("", 16, 40, 201, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit

       EndSwitch
    WEnd
    flapjack
    flapjack
    PSsix Member Super Class III
    PSsix Member Super Class III


    PSsix Moderator PSsix Master PSsix Game Coder
    จำนวนข้อความ : 314
    ความนิยม : 75
    เข้าร่วมเมื่อ : 05/10/2010

    ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ Empty Re: ช่วยหน่อยครับ ใส่ข้อความนึง แล้วให้แสดงอีกข้อความ

    ตั้งหัวข้อ by flapjack 12/06/14, 11:24 pm

    ลองไปประยุกต์ดูน่ะ ครับ
    Code:


    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>


    #Region ### START Koda GUI section ###
    $Form1 = GUICreate("Form1", 235, 85, 405, 257)
    $Input1 = GUICtrlCreateInput("", 16, 8, 121, 21)
    $Button1 = GUICtrlCreateButton("Button1", 144, 8, 75, 25)
    $Input2 = GUICtrlCreateInput("", 16, 40, 201, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###



    Global $file =  checkFile(FileOpen("text.txt",0 ))


    While 1

       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
                 FileClose($file)
               Exit
       Case $Button1
                   GUICtrlSetData($Input2,readFile(GUICtrlRead($Input1) ) )
       EndSwitch

    WEnd

    Func readFile($textinput)

    $text_file =  FileRead("text.txt",FileGetSize ("text.txt"))

    $word = check_LengthWord($text_file)

    $search_word =  search_Word($word,$textinput)

    Return $search_word

    EndFunc

    Func search_Word($word,$textinput)

       For $i=0  To UBound($word) -1

                            if ($word[$i][0]= $textinput) Then

                      Return $word[$i][1]
                  EndIf

        Next
        Return "No Word"
       EndFunc

    Func check_LengthWord($textfile)

    Dim $arrayre_split
    Local $str
    Local $sumindexarray
    Local $index = 0


         $array_string = StringSplit ($textfile,"")

    For $i=1 to  $array_string[0]

            If( Asc($array_string[$i]) = 13  )  Then     ; 13 =  CR (ASCII )
                 $sumindexarray = $sumindexarray + 1
            Else
             EndIf
        Next

         If Not $sumindexarray >0 Then
             Return ""
        EndIf

    Dim $arraystring[$sumindexarray][2]


    For $i=1  to  $array_string[0]

            If( Asc($array_string[$i]) = 13  )  And $index < $sumindexarray Then     ; 13 =  CR (ASCII )

                      $arrayre_split = StringSplit( StringRegExpReplace($str, "\r\n|\r|\n",''),"=")
                   $arraystring[$index][0] = $arrayre_split[1]
                   $arraystring[$index][1] = $arrayre_split[2]
                   $index = $index + 1
                   $str = ""
            Else
                   $str  = $str & $array_string[$i]
             EndIf
        Next
      Return $arraystring
    EndFunc


    Func checkFile($file)

    If $file = -1 Then
        MsgBox(0, "Error", "File Not Found.")
        Exit
    EndIf
       Return $file
       EndFunc

    ส่วนเนื้อหาข้างในของไฟล์ text.txt  (ต้องอยู่ที่เดียวกันกับไฟล์สคริปที่เขียน น่ะครับ)
    Code:

    ASD=SDF
    WEW=AXC
    ASD=CSAD
    SDSD=WSD

      เวลาขณะนี้ 28/03/24, 06:01 pm