Cov txheej txheem:

Programming hauv VB6: Cov Lus Qhia thiab Cov Lus Qhia: 3 Kauj Ruam
Programming hauv VB6: Cov Lus Qhia thiab Cov Lus Qhia: 3 Kauj Ruam

Video: Programming hauv VB6: Cov Lus Qhia thiab Cov Lus Qhia: 3 Kauj Ruam

Video: Programming hauv VB6: Cov Lus Qhia thiab Cov Lus Qhia: 3 Kauj Ruam
Video: Qhia program vb.net server connection remember method 2024, Kaum ib hlis
Anonim
Programming hauv VB6: Cov Lus Qhia thiab Cov Lus Qhia
Programming hauv VB6: Cov Lus Qhia thiab Cov Lus Qhia

Kuv ua haujlwm nyob rau hauv kuv lub sijhawm so, thiab kuv yog tus kws tshaj lij uas paub siv VB6. Nws yog ib qho yooj yim thiab kuv tseem tsis tau pom dab tsi uas kuv xav tau kom ua tiav uas nws ua tsis tau, txawm hais tias qee zaum nws tuaj yeem ua tiav kom ua tiav koj txoj haujlwm. Nrog txoj kev kuv pom muaj ntau yam tsis txaus ntseeg feem ntau yog txoj hauv kev nws suav qee yam. Yog li ntawm no yog qhov muab tso ua ke ntawm qee yam kuv tau kawm raws txoj kev. Kuv yaum koj yog tias koj muaj teeb meem tawm tswv yim thiab kuv yuav sim pab nrog cov kauj ruam ntxiv.

Kauj Ruam 1: Cov hlua

Cov hlua
Cov hlua

Txoj kev VB cuam tshuam nrog cov hlua tsis meej pem qee zaum.texta = "abcdefg" muab "cov cim rau ntawm ob sab ntawm cov ntawv koj xav kom suav ua ib txoj hluaMid (Txoj hlua, Pib, Ntev) xaiv ib ntu ntawm cov ntawv los ntawm cov hlua hlua tsis muaj xoom pib cov hlua pib ntawm 1textb = nruab nrab (texta, 2, 2) qhov no ua rau qhov sib txawv textb = "bc" textb = nruab nrab (texta, 4, 4) qhov no ua rau qhov sib txawv textb = "defg" textb = nruab nrab (texta, 4, 5) qhov no ua rau qhov sib txawv textb = "defg" Yog lawm yog tias cov ntawv koj tab tom sim xaiv yog ntev dua tom qab ntawv muaj cov ntawv nws xaus ntawm tus yam ntxwv kawg nyob ntawm koj qhov haujlwm koj yuav tau tso cov ntxiab kom tsis txhob ua yuam kev. yog ib qho cuab ntxiab: textb = nruab nrab (texta, 4, 5) yog len (textb) <5 ces 'Len () rov qab qhov ntev ntawm txoj hlua <txhais tau tias tsawg dua cesmsgbox "ntawv luv heev" "Qhia lub npov lus nrog stringexit sub 'Qhov no tawm hauv sub koj nyob hauv. xaus txoj cai. yog tias koj nyob hauv txoj haujlwm ces koj yuav tso tawm functionend iffinding qhov chaw ntawm tus cwj pwm hauv txoj hlua siv instr (Pib, Stri ng1, String2) texta = "abcdefg" textb = instr (1, texta, "c") 'qhov no pom tsab ntawv c hauv kab ntawv textatextb tam sim no sib npaug 3NOTE: Instr rov qab 0 (xoom) yog tias nws tsis pom tus yam ntxwv REORGANIZING: qhov no yog ib qho tsis txaus ntseeg koj xav kom "abcdefg" ua "defgabc" texta = "abcdefg" textb = nruab nrab (texta, 4, 4) & nruab nrab (texta, 1, 3) Qhov ntawd tsis phem heev tab sis tam sim no cia ntxiv rau hauv instr () muaj nuj nqi hais tias koj xav rov txhim kho txoj hlua ntawm daim kab xev tab sis nws tsis yog tib qhov chaw txhua lub sijhawm = "abcdefg" textb = "gfabdec" textc = nruab nrab (texta, instr (1, texta, "c"), len (texta) - instr (1, texta, "c") + 1) & nruab nrab (texta, 1, instr (1, texta, "c") - 1) nco ntsoov ntu len (texta) - instr (1, texta, " c ") + 1 vim tias instr suav tus cim koj tab tom nrhiav yog li koj rov qab ua ib tus cim kom nruab nrab () siv tus cwj pwm uas koj tab tom nrhiav ua thawj zaug hauv kab ntawv kab ntawv tam sim no sib npaug" cdefgab "textd = nruab nrab (textb, instr (1, textb, "c"), len (textb) - instr (1, textb, "c") + 1) & nruab nrab (textb, 1, instr (1, textb, "c") - 1) textd tam sim no equa ls "cgfabde" cia sim nrhiav tus ua cim uas tsis nyob hauv txoj kab ntawv textte = "abcdefg" textc = nruab nrab (texta, instr (1, texta, "h"), len (texta) - instr (1, texta, "h") + 1) & nruab nrab (texta, 1, instr (1, texta, "h") - 1) koj tau txais qhov yuam kev vim qhov pib ib nrab ntawm Mid () tsis tuaj yeem = 0 txij li cov hlua pib ntawm 1 yog li koj yuav tsum zam lub sijhawm ua haujlwm yuam kev Nov yog ib txoj hauv kev ua ittexta = "abcdefg" yog instr (1, texta, "h") 0 thentextc = nruab nrab (texta, instr (1, texta, "h"), len (texta) - instr (1, texta, "h") + 1) & nruab nrab (texta, 1, instr (1, texta, "h") - 1) lwm tus 'tsuas yog ib qho lus tshaj tawm ib zaug yog tias xwm txheej msgbox "Tsis tuaj yeem pom tus cim hauv txoj hlua"' qhia lub thawv ntawv nrog stringend ifThis suav tag nrho txhua yam uas koj xav paub txog cov hlua

Kauj ruam 2: Hloov Cov Cim

Hloov Cov Cim
Hloov Cov Cim

HEX: Ib qho kuv pom ua ntej lub lim tiam no yuav tsum ua nrog Hex (tus lej) ua haujlwm qhov ntev ntawm tus lej tsis muaj teeb meem.it rov xa ib txoj hlua hauv hexhex (11111111) rov "A98AC7" thaum hloov tus ascii cim rau hex koj yuav dotexta = "a" hex (asc (texta)) xa rov qab "61" texta = "k" hex (asc (texta)) rov qab "6B" txoj hlua yuav yog 2 tus cim rau NTAWM ASCI cov cim tsis muaj tus nqi qis dua 16 tom qab ntawd nws tsuas yog rov ua 1 tus yam ntxwv koj xav kom lawv txhua tus yog 2 tus cim koj yuav ua raws li hauv qab no: textb = hex (asc (texta)) yog len (textb) = 1 thentextb = "0" thiab textb 'uas yog xoom tsis yog peev nyiaj ntxiv yog tias

Kauj ruam 3: Hloov kho cov ntaub ntawv

Kho kom raug cov ntaub ntawv
Kho kom raug cov ntaub ntawv

txhawm rau qhib cov ntawv koj xav tau freefile thiab filenamegfile = FreeFile 'gfile yog tam sim no muaj freefilec = "c: test.txt" tom qab ntawd muaj 4 txoj hauv kev koj tuaj yeem qhib fileInput - Koj tuaj yeem nyeem nkaus xwb. Output - Koj tsuas tuaj yeem sau thiab nws yuav lwv cov ntaub ntawv yog tias nws muaj. nqa rov qab thiab kab ntawv kab ntawv kawg cov tsiaj ntawv Ntxiv - Koj tsuas tuaj yeem sau ntawv. nws yuav ntxiv rau cov ntawv uas twb muaj lawm. kev thauj rov qab thiab kab ntawv kab cim kawg Tus lej Binary - Nyeem thiab sau. meej heev tsuas yog ib qho uas kuv siv tam sim no. rau tsim cov ntaub ntawv cav thiab kev siv txuas ntxiv nws yuav ntxiv qhov nkag tshiab mus rau qhov kawg ntawm cov ntaub ntawv. rau cov ntaub ntawv nyuaj dua thauj cov ntaub ntawv tag nrho rau hauv qhov sib txawv thiab ntxiv qhov nkag tshiab rau thaum pib ntawm file.dim stro raws li txoj hlua 'qhov no tsim nyog lossis yuav muaj qhov yuam kev gfile = FreeFilec = "c: test.txt" qhib c rau binary li #gfile' nco gfile yog tus lej = qhov chaw $ (lof (gfile)) 'thaum qhib rau binary koj yuav tsum qhia loj npaum li cas qhov ntev ntawm cov ntawv koj xav coj yog lof (gfile) yuav rov qab qhov ntev ntawm gfile thiab qhov chaw $ () rov qab txoj hlua ntawm qhov ntev ntawm tus lej koj nkag mus #gfile, 1, stro 'tau txais los ntawm cov ntaub ntawv tus lej, pib byte, hloov pauv kom txuag nws rau. thiab thauj tsuas yog qhov ntev ntawm qhov sib txawv kaw #gfilestro tam sim no yog sib npaug rau cov ntawv xeem.txt.you tuaj yeem tso cov ntaub ntawv rau hauv cov ntaub ntawv byffile = FreeFilestro = "Kab tshiab" & VbCrLf & stro 'ntxiv "Kab tshiab" thiab carraige rov qab thiab linefeed ua raws los ntawm cov ntawv qub qub rau binary li #ffilekill cput #ffile, 1, stro 'muab cov ntaub ntawv sau tseg yav dhau los yog tias cov ntawv tau me dua koj yuav tsum tua cov ntawv ua ntej uas tshem tawm nws kaw #ffilethe cov ntaub ntawv tam sim no muaj "Kab tshiab" hauv nws ib yam Kuv pom nrog kev tso ua haujlwm yog nws muaj qhov yuam kev yog tias koj sim muab tus cim zoo li #ffile, 133, chr (1) 'qhov no hloov tus cwj pwm ntawm byte 133 nrog tus cim 1 lossis hex 0x01I pom thaum kuv ua qhov no nrog ib qho program kuv ua nws tau ntxiv hex 0x08000100000001 uas yog freaking wierd. Kuv daws qhov no los ntawm kev thauj cov ntawv mus rau qhov sib txawv thiab ua txoj hlua modsi = 133stro = nruab nrab (stro, 1, i - 1) & chr (1) & nruab nrab (stro, i + 1, len (stro) - i) ces muab #ffile, 1, strothis ua haujlwm tau zoo

Pom zoo: