Tài liệu Viết lại một số thuật toán trong sách dưới dạng các unit.

  • Số trang: 26 |
  • Loại file: PDF |
  • Lượt xem: 61 |
  • Lượt tải: 0
nganguyen

Đã đăng 34345 tài liệu

Mô tả:

Website: http://www.docs.vn Email : lienhe@docs.vn Tel : 0918.775.368 Lêi nãi ®Çu Ngµy nay c«ng nghÖ th«ng tin ®· vµ ®ang ngµy cµng mét ph¸t triÓn nh- vò b·o, nã ®· x©m nhËp vµo mäi lÜnh vùc nh- khoa häc kü thuËt, kinh tÕ, chÝnh trÞ,…S¶n phÈm cña c«ng nghÖ th«ng tin chñ yÕu lµ c¸c phÇn mÒm øng dông. Mét trong nh÷ng øng dông quan träng nhÊt chÝnh lµ viÖc øng dông trong qu¶n lý. PhÇn mÒm qu¶n lý phæ biÕn hiÖn nay vµ ®-îc øng dông kh¸ phæ biÕn chÝnh lµ Micrsoft Excel. PhÇn mÒm nµy ®-îc t¹o ra ®· gióp cho ng-êi qu¶n lý tæ chøc c«ng viÖc mét c¸ch nhanh chãng, chÝnh x¸c vµ cã hiÖu qu¶. Ch-¬ng tr×nh chñ yÕu ®-îc sö dông ®Ó viÕt nªn phÇn mÒm nµy chÝnh lµ Visual Basic. Trªn c¬ së ®· ®-îc häc m«n LËp tr×nh h-íng ®èi t-îng víi Visual Basic, t«i chän ®Ò tµi: “X©y dùng mét ch-¬ng tr×nh t-¬ng tù nhMicrosoft Excel víi c¸c chøc n¨ng c¬ b¶n sau: 1. Cho phÐp t¹o ra c¸c b¶ng tÝnh . 2. Cho phÐp gâ d÷ liÖu thuéc c¸c d¹ng kh¸c nhau. 3. Cho phÐp chän th- môc ®Ó in ra file míi, më file ®· cã. 4. Cho phÐp thùc hiÖn c¸c phÐp tÝnh sè häc theo hµng vµ cét 5. Cho phÐp c¾t, d¸n d÷ liÖu trªn b¶ng 6. Cho phÐp chän c¸c Font ch÷ kh¸c nhau ®Ó so¹n” Tuy nhiªn, ®©y chØ lµ mét ch-¬ng tr×nh m« pháng l¹i MS Excel mét c¸ch c¬ b¶n, ®¬n gi¶n nhÊt dùa trªn nh÷ng kiÕn thøc mµ t«i ®· ®-îc häc tËp t¹i khoa CNTT nªn c¸c thuËt to¸n ch-a ®-îc hîp lý vµ c¸ch tr×nh bµy cã thÓ cßn nhiÒu thiÕu sãt. V× vËy, t«i rÊt mong nhËn ®-îc sù gãp ý cña thÇy c« vµ c¸c b¹n ®Ó ch-¬ng tr×nh ®-îc hoµn thiÖn h¬n. T«i xin ch©n thµnh c¶m ¬n thÇy gi¸o: GS.TS. NguyÔn V¨n XuÊt vµ thÇy gi¸o NguyÔn Qu¶ng Hµ ®· h-íng dÉn t«i lµm ch-¬ng tr×nh nµy. 1 Néi dung ®Ò tµI I. TÝnh cÊp thiÕt cña ®Ò tµI Cïng víi sù ph¸t triÓn m¹nh mÏ cña c«ng nghÖ th«ng tin vµ cïng víi xù x©m nhËp nhanh chãng cña tin häc vµo mäi lÜnh vùc cña ®êi sèng x· héi th× viÖc sö dông m¸y tÝnh trong c«ng t¸c qu¶n lý ®· trë thµnh mét nhu cÇu cÊp b¸ch, nã lµ mét trong nh÷ng c«ng cô kh«ng thÓ thiÕu nh»m n©ng cao chÊt l-îng vµ hiÖu qu¶ trong c«ng t¸c qu¶n lý. C¸i khã khi qu¶n lý lµ thao t¸c víi c¸c lo¹i d÷ liÖu kh¸c nhau vèn rÊt ®a d¹ng ch-a kÓ tíi viÖc tÝnh to¸n, sao chÐp, l-u tr÷,…®iÒu nµy t¹o ra khã kh¨n cho nh÷ng ng-êi lËp tr×nh, ®Æc biÖt lµ lËp tr×nh víi Excel – mét ch-¬ng tr×nh qu¶n lý ®· kh¸ phæ biÕn tõ tr-íc tíi nay. Do vËy, viÖc n©ng cÊp ch-¬ng tr×nh nµy ngµy cµng ph¶i ®-îc thay ®æi mét c¸ch th-êng xuyªn h¬n. II. Môc ®Ých cña ®Ò tµI Bµi tiÓu luËn m«n häc nµy phÇn nµo ®-a ra mét c¸ch nh×n c¬ b¶n khi x©y dùng mét ch-¬ng tr×nh t-¬ng tù nh- MS Excel. Ch-¬ng tr×nh kh¸ ®¬n gi¶n víi 6 chøc n¨ng c¬ b¶n: 1. Cho phÐp t¹o ra c¸c b¶ng tÝnh . 2. Cho phÐp gâ d÷ liÖu thuéc c¸c d¹ng kh¸c nhau (kiÓu sè, kiÓu ký tù, c¸c ký hiÖu ®Æc biÖt,…) 3. Cho phÐp chän th- môc ®Ó in ra file míi, më file ®· cã. 4. Cho phÐp thùc hiÖn c¸c phÐp tÝnh sè häc (céng, trõ, nh©n, chia) theo hµng vµ cét. 5. Cho phÐp c¾t, d¸n d÷ liÖu trªn b¶ng 6. Cho phÐp chän c¸c Font ch÷ kh¸c nhau ®Ó so¹n III. S¬ ®å thiÕt kÕ: Thanh menu gåm cã 4 môc  Menu File  Menu Edit  Menu View  Menu Help Ngoµi ra b¹n cã thÓ sö dông thanh c«ng cô ®Ó ®iÒu khiÓn cã chøc n¨ng gièng nh- thanh menu. 2 IV. C¸c ®èi t-îng, c«ng cô sö dông:  MSHFlex Grid  Microsoft Common Dialog Control  TextBox  Command Button  Image List  Label V. Khi Ch¹y ch-¬ng tr×nh: Tr-íc tiªn ®Ó ch¹y ®-îc ch-¬ng tr×nh nµy th× m¸y tÝnh cña b¹n ph¶i cã Microsoft Visual Basic 6.0. V.1 Khi ch¹y ch-¬ng tr×nh b¹n cã thÓ më file cò hoÆc më file míi ®Ó lµm viÖc 3 V.2 Ngoµi ra b¹n cã thÓ chän Font, cì ch÷ ®Ó so¹n th¶o c¸c BookSheet nh- b¹n muèn. Råi l-u l¹i víi mét file 4 V.3 ViÖc tÝnh to¸n víi c¸c phÐp tÝnh sè häc còng ®-îc thùc hiÖn ngay trªn b¶ng tÝnh 5 V.4 T-¬ng tù viÖc c¾t, d¸n d÷ liÖu còng vËy, ®Òu thùc hiÖn trùc tiÕp trªn b¶ng VI. Code ch-¬ng tr×nh nguån: FORM MDIMAIN Private Sub Command1_Click() If Text2.Text <> "" Then Call Tinh(Trim(Text2.Text)) Else MsgBox "Formula is null", vbCritical, "Warning" End If End Sub Private Sub Label3_Click() With CommonDialog1 .CancelError = True On Error GoTo No_Font_Chosen .Flags = 1 .ShowFont 6 If ActiveForm Is Nothing Then Exit Sub ActiveForm.Grid1.CellFontName = .FontName 'Text2.FontName = .FontName ActiveForm.Grid1.CellFontSize = .FontSize 'Text2.FontSize = .FontSize ActiveForm.Grid1.CellFontBold = .FontBold 'Text2.FontBold = .FontBold ActiveForm.Grid1.CellFontUnderline = .FontUnderline 'Text2.FontUnderline = .FontUnderline ActiveForm.Grid1.CellFontItalic = .FontItalic 'Text2.FontItalic = .FontItalic ActiveForm.Grid1.FontStrikethru = .FontStrikethru On Error GoTo 0 Exit Sub End With No_Font_Chosen: End Sub Private Sub Label5_Click() Picture4.Visible = False mnuFormula.Checked = False mnuPopupFormula.Checked = False End Sub Private Sub MDIForm_Load() Me.WindowState = 2 Text2.Text = "" Text3.Text = "" ToolBar1.Height = 329 Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000) Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000) Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500) Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500) LoadNewBook End Sub Private Sub LoadNewBook() Static LBookCount As Long Dim frmB As frmExcel LBookCount = LBookCount + 1 Set frmB = New frmExcel 7 frmB.Caption = "Book" & LBookCount frmB.Tag = LBookCount frmB.Show End Sub Private Sub MDIForm_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = vbRightButton Then PopupMenu mnuFile End If End Sub Private Sub MDIForm_Unload(Cancel As Integer) If Me.WindowState <> vbMinimized Then SaveSetting App.Title, "Settings", "MainLeft", Me.Left SaveSetting App.Title, "Settings", "MainTop", Me.Top SaveSetting App.Title, "Settings", "MainWidth", Me.Width SaveSetting App.Title, "Settings", "MainHeight", Me.Height End If Unload frmExcel End End Sub Private Sub mnuClose_Click() Call mnuFileClose_Click End Sub Private Sub mnuCopy_Click() Call mnuEditCopy_Click End Sub Private Sub mnuCut_Click() Call mnuEditCut_Click End Sub Private Sub mnuEditFind_Click() Find.Show End Sub Private Sub mnuExit_Click() Call mnuFileExit_Click 8 End Sub Private Sub mnuFont_Click() Call Label3_Click End Sub Private Sub mnuFormula_Click() mnuFormula.Checked = Not mnuFormula.Checked Picture4.Visible = mnuFormula.Checked End Sub Private Sub mnuNew_Click() LoadNewBook End Sub Private Sub mnuOpen_Click() Call mnuFileOpen_Click End Sub Private Sub mnuPaste_Click() Call mnuEditPaste_Click End Sub Private Sub mnuPopupFormula_Click() mnuPopupFormula.Checked = Not mnuPopupFormula.Checked Picture4.Visible = mnuPopupFormula.Checked End Sub Private Sub mnuViewStatusBar_Click() mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked sbStatusBar.Visible = mnuViewStatusBar.Checked End Sub Private Sub mnuViewToolbar_Click() mnuViewToolbar.Checked = Not mnuViewToolbar.Checked tbToolBar.Visible = mnuViewToolbar.Checked End Sub End Sub Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button) If ActiveForm Is Nothing Then Exit Sub 9 On Error Resume Next Select Case Button.Key Case "New" LoadNewBook Case "Open" mnuFileOpen_Click Case "Save" mnuFileSave_Click Case "Print" mnuFilePrint_Click Case "Cut" mnuEditCut_Click Case "Copy" mnuEditCopy_Click Case "Paste" mnuEditPaste_Click Case "Bold" ActiveForm.Grid1.CellFontBold = Not ActiveForm.Grid1.CellFontBold Button.Value = IIf(ActiveForm.Grid1.CellFontBold, tbrPressed, tbrUnpressed) Case "Italic" ActiveForm.Grid1.CellFontItalic = Not ActiveForm.Grid1.CellFontItalic Button.Value = IIf(ActiveForm.Grid1.CellFontItalic, tbrPressed, tbrUnpressed) Case "Underline" ActiveForm.Grid1.CellFontUnderline = Not ActiveForm.Grid1.CellFontUnderline Button.Value = IIf(ActiveForm.Grid1.CellFontUnderline, tbrPressed, tbrUnpressed) Case "Align Left" ActiveForm.Grid1.CellAlignment = 1 Case "Center" ActiveForm.Grid1.CellAlignment = 4 Case "Align Right" ActiveForm.Grid1.CellAlignment = 7 Case "Sort Ascending" 'ActiveForm.Grid1.Sort = 1 Call Sort_Asc Case "Sort Descending" 10 'ActiveForm.Grid1.Sort = 2 Call Sort_Desc Case "Find" Find.Show End Select End Sub Public Sub Sort_Asc() Dim i, j, x, x1, y, y1 As Long x=1 y=1 x1 = ActiveForm.Grid1.Row 'MaxRow - 1 y1 = ActiveForm.Grid1.Col 'MaxCol - 1 For i = x To x1 For j = y To y1 fMainForm.ActiveForm.Grid1.Row = i fMainForm.ActiveForm.Grid1.Col = j fMainForm.ActiveForm.Grid1.Sort = 1 'Asc Next j Next i End Sub Public Sub Sort_Desc() Dim i, j, x, x1, y, y1 As Long x=1 y=1 x1 = ActiveForm.Grid1.Row 'MaxRow - 1 y1 = ActiveForm.Grid1.Col 'MaxCol - 1 For i = x To x1 For j = y To y1 fMainForm.ActiveForm.Grid1.Row = i fMainForm.ActiveForm.Grid1.Col = j fMainForm.ActiveForm.Grid1.Sort = 2 'Desc Next j Next i End Sub Private Sub mnuHelpAbout_Click() frmAbout.Show vbModal, Me End Sub 11 Private Sub mnuEditCopy_Click() On Error Resume Next Clipboard.SetText ActiveForm.Grid1.TextMatrix(ActiveForm.Grid1.Row, ActiveForm.Grid1.Col) End Sub Private Sub mnuEditPaste_Click() On Error Resume Next ActiveForm.Grid1.TextMatrix(ActiveForm.Grid1.Row, ActiveForm.Grid1.Col) = Clipboard.GetText End Sub Private Sub mnuEditCut_Click() On Error Resume Next Clipboard.SetText ActiveForm.Grid1.TextMatrix(ActiveForm.Grid1.Row, ActiveForm.Grid1.Col) ActiveForm.Grid1.TextMatrix(ActiveForm.Grid1.Row, ActiveForm.Grid1.Col) = vbNullString End Sub Private Sub mnuFileExit_Click() 'unload the form Unload frmExcel End End Sub Private Sub mnuFilePrint_Click() On Error Resume Next If ActiveForm Is Nothing Then Exit Sub With dlgCommonDialog .DialogTitle = "Print" .CancelError = True .Flags = cdlPDReturnDC + cdlPDNoPageNums If ActiveForm.Grid1.SelLength = 0 Then .Flags = .Flags + cdlPDAllPages Else .Flags = .Flags + cdlPDSelection End If .ShowPrinter If Err <> MSComDlg.cdlCancel Then 12 ActiveForm.Grid1.SelPrint .hDC End If End With End Sub Private Sub mnuFileSaveAs_Click() Dim sFile As String If ActiveForm Is Nothing Then Exit Sub With CommonDialog2 .DialogTitle = "Save As" .CancelError = False 'ToDo: set the flags and attributes of the common dialog control .Filter = "Book(*.Mp5)|*.Mp5|All Files (*.*)|*.*" .FilterIndex = 1 .ShowSave If Len(.filename) = 0 Then Exit Sub End If sFile = .filename End With ActiveForm.Caption = sFile Saved sFile End Sub Private Sub mnuFileSave_Click() Dim sFile As String If ActiveForm Is Nothing Then Exit Sub If Left$(ActiveForm.Caption, 4) = "Book" Then With CommonDialog2 .DialogTitle = "Save" .CancelError = False .Filter = "Book(*.Mp5)|*.Mp5|All Files (*.*)|*.*" .filename = Left$(ActiveForm.Caption, 4) .FilterIndex = 1 .ShowSave If Len(.filename) = 0 Then Exit Sub End If sFile = .filename End With 13 Saved sFile Else sFile = ActiveForm.Caption Saved sFile End If End Sub Private Sub mnuFileClose_Click() ActiveForm.Hide End Sub Private Sub mnuFileOpen_Click() Dim sFile As String If ActiveForm Is Nothing Then LoadNewBook With CommonDialog2 .DialogTitle = "Open" .CancelError = False .Filter = "Book(*.Mp5)|*.Mp5|All Files (*.*)|*.*" .FilterIndex = 1 .ShowOpen If Len(.filename) = 0 Then Exit Sub End If sFile = .filename End With Opened sFile ActiveForm.Caption = sFile End Sub Private Sub mnuFileNew_Click() LoadNewBook End Sub Private Sub Text2_Change() If ActiveForm Is Nothing Then Exit Sub ActiveForm.Grid1.Text = Text2.Text End Sub Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then Call Tinh(Trim(Text2.Text)) 14 End If End Sub Private Sub Text3_Click() Text3.Alignment = vbLeftJustify End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) Dim st, st2, st3 As String Dim i, L, k As Long If ActiveForm Is Nothing Then Exit Sub If KeyAscii = 13 Then On Error Resume Next st = UCase(Trim(Text3.Text)) L = Len(st) For i = 1 To L + 1 If Asc(Mid(st, i, 1)) >= 48 And Asc(Mid(st, i, 1)) <= 57 Then GoTo L2 End If Next i L2: st2 = Left(st, i - 1) st3 = Right(st, Len(st) - i + 1) If Len(st2) = 1 Then ActiveForm.Grid1.Col = Asc(UCase(st2)) - 64 ElseIf Len(st2) = 2 Then k = Asc(UCase(Left(st2, 1))) - 64 + 26 ActiveForm.Grid1.Col = k End If ActiveForm.Grid1.Row = Val(st3) ActiveForm.Grid1.FocusRect = flexFocusLight End If End Sub Private Sub Text3_Validate(Cancel As Boolean) Text3.Alignment = vbCenter End Sub FORM frmExcel Private Sub rtfText_SelChange() 15 ' fMainForm.tbToolBar.Buttons("Bold").Value = IIf(rtfText.SelBold, tbrPressed, tbrUnpressed) ' fMainForm.tbToolBar.Buttons("Italic").Value = IIf(rtfText.SelItalic, tbrPressed, tbrUnpressed) ' fMainForm.tbToolBar.Buttons("Underline").Value = IIf(rtfText.SelUnderline, tbrPressed, tbrUnpressed) ' fMainForm.tbToolBar.Buttons("Align Left").Value = IIf(rtfText.SelAlignment = rtfLeft, tbrPressed, tbrUnpressed) ' fMainForm.tbToolBar.Buttons("Center").Value = IIf(rtfText.SelAlignment = rtfCenter, tbrPressed, tbrUnpressed) ' fMainForm.tbToolBar.Buttons("Align Right").Value = IIf(rtfText.SelAlignment = rtfRight, tbrPressed, tbrUnpressed) End Sub Private Sub Form_Load() Dim i, j, k As Integer Me.WindowState = 2 Grid1.MousePointer = flexSizeAll Grid1.Rows = MaxRow '1000 Grid1.Cols = MaxCol '101 Grid1.Row = 0 For i = 1 To MaxCol - 1 Grid1.Col = i Grid1.CellAlignment = 4 'center If Grid1.Col > 26 Then 'Columns AA->... Grid1.Text = Chr(Int((Grid1.Col - 1) / 26) + 64) & Chr(((Grid1.Col - 1) Mod 26) + 65) Else ' Columns A-Z Grid1.Text = Chr(Grid1.Col + 64) End If Next i Grid1.Col = 0 For i = 1 To Grid1.Rows - 1 Grid1.Row = i Grid1.CellAlignment = 4 'Center Grid1.Text = Str(i) Grid1.ColWidth(0) = 550 Next i Grid1.Col = 1 'Vitri ban dau cua TextMain 16 Grid1.Row = 1 End Sub Private Sub Form_Resize() Grid1.Height = ScaleHeight Grid1.Width = ScaleWidth End Sub Private Sub Form_Unload(Cancel As Integer) Dim i As Integer i = MsgBox("Do you want to save change you made to this 'Book'?", vbYesNoCancel + vbDefaultButton1 + vbExclamation, "Excel 2003") If i = vbYes Then Call save_form End If If i = vbCancel Then Cancel = 1 Exit Sub End Sub Public Sub save_form() Dim sFile As String With fMainForm.CommonDialog2 .DialogTitle = "Save" .CancelError = False .Filter = "Book(*.Mp5)|*.Mp5|All Files (*.*)|*.*" .filename = Left$(frmExcel.Caption, 4) .FilterIndex = 1 .ShowSave If Len(.filename) = 0 Then Exit Sub End If sFile = .filename End With Saved sFile End Sub Private Sub Grid1_Click() fMainForm.Text3.Alignment = vbCenter 'Name Box fMainForm.Text2.Text = "" fMainForm.sbStatusBar.Panels(1).Text = " Ready" End Sub Private Sub Grid1_DblClick() fMainForm.Text3.Alignment = vbCenter 17 End Sub Private Sub Grid1_KeyPress(KeyAscii As Integer) fMainForm.sbStatusBar.Panels(1).Text = " Enter" If KeyAscii <> 13 And KeyAscii <> 9 And KeyAscii <> 8 Then Grid1.Text = Grid1.Text + Chr(KeyAscii) fMainForm.Text2.Text = Grid1.Text ' If Len(Grid1.Text) > Grid1.CellWidth Then ' Grid1.CellWidth = Len(Grid1.Text) ' End If End If If KeyAscii = 13 Then If Left(Grid1.Text, 1) = "=" Then Tinh Grid1.Text Else Grid1.Row = Grid1.Row + 1 End If End If If KeyAscii = 9 Then Grid1.Col = Grid1.Col + 1 'Phim Tab If KeyAscii = 8 And Grid1.Text <> "" Then 'Phim Back Grid1.Text = Left(Grid1.Text, Len(Grid1.Text) - 1) End If End Sub Private Sub Grid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'Name box fMainForm.Text3.Text = Trim(Grid1.TextMatrix(Grid1.RowPos(0), Grid1.Col)) & Trim(Grid1.TextMatrix(Grid1.Row, Grid1.ColPos(0))) 'Grid1.Row = Grid1.RowPos(0) 'Grid1.CellBackColor = vbRed 'Grid1.Col = Grid1.ColPos(0) 'Grid1.CellBackColor = vbRed If Button = vbRightButton Then PopupMenu fMainForm.mnuPopup End If End Sub MODUL.BAS Option Explicit 18 Public Const MaxCol As Long = 51 '101 Public Const MaxRow As Long = 201 '1001 Global Hang, Cot As Long Public fMainForm As MDIMain Sub Main() frmSplash.Show frmSplash.Refresh Set fMainForm = New MDIMain Load fMainForm Unload frmSplash fMainForm.Show End Sub Public Sub Tinh(s As String) Dim i, j, x, y, xt, yt, tg, dau As Integer Dim kq As Double Dim s1, Flag As String Dim Zero As Boolean 'On Error GoTo L3 s = UCase(Right(s, Len(s) - 1)) xt = fMainForm.ActiveForm.Grid1.Row yt = fMainForm.ActiveForm.Grid1.Col tg = Len(s) dau = 0 Zero = False For i = 1 To tg Select Case Left(s, 1) Case "+": x = Asc(Left(s1, 1)) - 64 y = Val(Right(s1, Len(s1) - 1)) fMainForm.ActiveForm.Grid1.Row = y fMainForm.ActiveForm.Grid1.Col = x kq = kq + Val(fMainForm.ActiveForm.Grid1.Text) s1 = "" Flag = "+" Case "-": x = Asc(Left(s1, 1)) - 64 y = Val(Right(s1, Len(s1) - 1)) fMainForm.ActiveForm.Grid1.Row = y fMainForm.ActiveForm.Grid1.Col = x kq = kq - Val(fMainForm.ActiveForm.Grid1.Text) If dau = 0 Then 19 kq = kq * -1 dau = 1 End If 'MsgBox x & "" & y & " " & kq s1 = "" Flag = "-" Case "*": x = Asc(Left(s1, 1)) - 64 y = Val(Right(s1, Len(s1) - 1)) If dau = 0 Then kq = 1 dau = 1 End If fMainForm.ActiveForm.Grid1.Row = y fMainForm.ActiveForm.Grid1.Col = x kq = kq * Val(fMainForm.ActiveForm.Grid1.Text) 'MsgBox x & "" & y & " " & al(fMainForm.ActiveForm.Grid1.Text) s1 = "" Flag = "*" Case ":": x = Asc(Left(s1, 1)) - 64 y = Val(Right(s1, Len(s1) - 1)) fMainForm.ActiveForm.Grid1.Row = y fMainForm.ActiveForm.Grid1.Col = x If dau = 0 Then kq = Val(fMainForm.ActiveForm.Grid1.Text) dau = 1 Else If Val(fMainForm.ActiveForm.Grid1.Text) <> 0 Then kq = kq / Val(fMainForm.ActiveForm.Grid1.Text) Else MsgBox "Division by zero", vbCritical, "Warning" Zero = True End If End If s1 = "" Flag = ":" Case Else s1 = s1 & Left(s, 1) End Select s = Right(s, Len(s) - 1) 20
- Xem thêm -