【文章內(nèi)容簡(jiǎn)介】
st(int1)= Text1(k).TextEnd IfText1(k).Text = ”“: Text1(k).Locked = TrueCmdxg(k).Enabled = False: Cmdsc(k).Enabled = FalseCmdtj(k).SetFocus End Sub 后面一段當(dāng)時(shí)看來顯得很費(fèi)精力,因?yàn)樾枰孕性O(shè)定加密方法 Private Sub sure_click()Dim i As Integer, password As Long i = 1If ThenMsgBox ”兩次密碼不一樣(~?!?,請(qǐng)重新輸入“, 48, ”提示“ElseIf Len(Trim(np)) 8 ThenMsgBox ”請(qǐng)保證密碼不超過8位“, 48MsgBox ”密碼已修改,a請(qǐng)記住您的密碼哦!“, 64, ”溫馨提示“End If Do While i = 1 np = np + Asc(Mid(, i, 1))Loop Open amp。 ”“ For Output As 139。設(shè)置密碼Write 1, npClose 1End SubPrivate Sub np_KeyPress(KeyAscii As Integer)If KeyAscii 48 Or KeyAscii 57 ThenKeyAscii = 039。密碼含非數(shù)字字符,則顯示錯(cuò)誤MsgBox ”密碼應(yīng)當(dāng)為數(shù)字,請(qǐng)重新輸入“, , ”提示“End IfElse39。兩次輸入一樣就加密并保存到文件 窗體frmlsz 窗體frmlsz供用戶輸入每日的收支帳目,即收支類型、收支時(shí)間、金額和備注。,便于用戶選擇相應(yīng)的類型輸入日常流水賬。為實(shí)現(xiàn)數(shù)據(jù)逐條讀寫采用do loop循環(huán) EOF()文件函數(shù)和input語句。利用If語句判斷data的int1取值,確定數(shù)據(jù)是收入還是支出,這是一種較為簡(jiǎn)便的方式,在后面的數(shù)據(jù)查詢中有很大的發(fā)揮空間Frmlsz在主界面中的default屬性被我改成了true。其結(jié)構(gòu)簡(jiǎn)單,但設(shè)計(jì)上還是需要注意些問題,比方說就看下面一段代碼,我們有時(shí)候確實(shí)有必要在細(xì)節(jié)上較真Private Sub Cmdbc_Click(Index As Integer)Dim j As Integer: j = Index Dim str1 As String If Coblb(j).Text = ”“ Or txtje(j).Text = ”“ Then 39。輸入信息MsgBox ”請(qǐng)輸入完整 oPrivate Sub cmdfh_Click(Index As Integer)39。返回 Unload Frmlsz End SubPrivate Sub Cmdqk_Click(Index As Integer)39。清空按鈕 Dim j As Integer: j = Index Coblb(j).Text = ”“: txtje(j).Text = ”“: txtbz(j).Text = ”“ End Sub 這段代碼基本上在所有類似的情況中都大同小異Private Sub Form_Load()39。讀取信息 Dim str1 As String Open amp。 ”“ For Input As 2 Do While Not EOF(2)Input 2, str1 Coblb(1).AddItem str1 Loop Open amp。 ”“ For Input As 1 Do While Not EOF(1)Input 1, str1 Coblb(0).AddItem str1 Loop Close End Sub frmcxtj 窗體frmcxtj算是對(duì)于上述窗體的綜合應(yīng)用。在數(shù)組的基礎(chǔ)上同時(shí)也涉及到了自定義變量類型,利用其尋找到時(shí)間或類別上符合要求的項(xiàng),通過EOF語句不斷賦值,再通過do loop循環(huán)得到。兩組單選框的value值改變而轉(zhuǎn)化frame的visible屬性,這是大致的思路框架。具體落實(shí)到代碼的編寫上,比方尋找時(shí)間段是通過與dtpicker的value值比較Private Sub Cmd3_Click()Dim newdata As data, i As Integer ‘此句為收入支出對(duì)比一欄上給兩個(gè)文本框計(jì)算的過程 Dim amount As Long, money1 As Long, money2 As Integer = ”從“ amp。 Space(3)amp。 amp。 Space(2)amp。 ”到“ amp。 Space(2)amp。 amp。 Space(2)amp。 ”期間“ ‘標(biāo)簽Open amp。 ”“ For Input As 1 Do While Not EOF(1)Input 1, Input 1, Input 1, Input 1, Input 1, If( =())And( =())And( Private Sub Cmd1_Click()’第一個(gè)確定按鈕 39。 Dim newdata As data, i As Integer Dim amount As Long, money As Long amount = 0 Open amp。 ”“ For Input As 1 39。當(dāng)選擇收入類型查詢時(shí)If = True Then Do While Not EOF(1)Input 1, Input 1, Input 1, Input 1, Input 1, If( =())And( =())And( Private Sub Cmd2_Click()第二個(gè)確定按鈕 Dim newdata As data, i As Integer Dim amount As Long, money As Long amount = 0Open amp。 ”“ For Input As 2 39。當(dāng)選擇支出類型查詢時(shí) If = True Then Do While Not EOF(2)Input 2, Input 2, Input 2, Input 2, Input 2, If( =())And( If( =())And Private Sub Command1_Click(Index As Integer)39。返回 Unload Me End SubPrivate Sub Form_Load()39。讀取信息 Dim str1 As String Open amp。 ”“ For Input As 2 Do While Not EOF(2)Input 2, str1 str1 Loop Open amp。 ” For Input As 1 Do While Not EOF(1)Input 1, str1 str1 Loop Close End Sub Private Sub Option1_Click()39。以下為單選框的四類情況 = False = True End SubPrivate Sub Option2_Click() = True = False End SubPrivate Sub Option3_Click() = True = False End SubPrivate Sub Option4_Click() = False = True End Sub 標(biāo)準(zhǔn)模塊標(biāo)準(zhǔn)模塊中我設(shè)立了自定義類型的變量用來聲明自定義數(shù)據(jù)類型 data,它有5個(gè)元素,其中int1為難點(diǎn)和重點(diǎn)。其值可用于區(qū)分收入和支出的性質(zhì),在frmcxj中顯得尤為重要,另外我就是剛才犯了個(gè)錯(cuò)誤,time 是關(guān)鍵字,在編寫程序時(shí)一直出現(xiàn)了溢出的錯(cuò)誤,幸好及時(shí)得到了改正,np,np2用來存放密碼,密碼的設(shè)立主要是通過把每個(gè)數(shù)字的ascii碼求出然后求和的過程,用到了Mid(),Asc(),Len()函數(shù)和For循環(huán)。Public np As Integer, np2 As Integer Public Type data int1 As Integer time1