home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form frmMain Caption = "XL Grid" ClientHeight = 4065 ClientLeft = 165 ClientTop = 735 ClientWidth = 8415 LinkTopic = "Form1" ScaleHeight = 4065 ScaleWidth = 8415 StartUpPosition = 3 'Windows Default Begin VB.Frame frFonts BorderStyle = 0 'None Height = 492 Left = 0 TabIndex = 13 Top = 840 Width = 6732 Begin VB.ComboBox cmbFunc Height = 288 Left = 4680 Sorted = -1 'True TabIndex = 18 Top = 120 Width = 1572 End Begin VB.ComboBox cmbFontSize Height = 288 Left = 2640 TabIndex = 16 Top = 120 Width = 732 End Begin VB.ComboBox cmbFonts Height = 288 Left = 600 TabIndex = 14 Top = 120 Width = 1692 End Begin VB.Label lblFormat Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "Valid Functions" Height = 192 Left = 3480 TabIndex = 17 Top = 120 Width = 1092 End Begin VB.Label Label4 Alignment = 2 'Center AutoSize = -1 'True Caption = "Font" Height = 192 Left = 144 TabIndex = 15 Top = 120 Width = 324 End End Begin MSComctlLib.ImageList ImageList1 Left = 840 Top = 2760 _ExtentX = 794 _ExtentY = 794 BackColor = -2147483643 ImageWidth = 32 ImageHeight = 32 MaskColor = 12632256 _Version = 393216 BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} NumListImages = 2 BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":0000 Key = "" EndProperty BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":0454 Key = "" EndProperty EndProperty End Begin VB.Frame Frame BorderStyle = 0 'None Height = 492 Left = 0 TabIndex = 3 Top = 360 Width = 7815 Begin VB.CommandButton Command2 Enabled = 0 'False Height = 252 Left = 7200 Picture = "frmMain.frx":08A8 Style = 1 'Graphical TabIndex = 11 Top = 120 Width = 492 End Begin VB.CommandButton Command1 Enabled = 0 'False Height = 252 Left = 6600 Picture = "frmMain.frx":0CEA Style = 1 'Graphical TabIndex = 10 Top = 120 Width = 492 End Begin VB.TextBox txtFormula Height = 288 Left = 3960 TabIndex = 9 Top = 120 Width = 2535 End Begin VB.TextBox txtCellVal Height = 288 Left = 2280 TabIndex = 7 Top = 120 Width = 1212 End Begin VB.TextBox txtRowCol Height = 288 Left = 720 TabIndex = 4 Top = 120 Width = 852 End Begin VB.Label Label3 Alignment = 2 'Center Caption = "=" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 372 Left = 3600 TabIndex = 8 Top = 120 Width = 252 End Begin VB.Label Label2 Alignment = 2 'Center Caption = "Value" Height = 372 Left = 1680 TabIndex = 6 Top = 120 Width = 612 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "Cell" Height = 852 Left = -120 TabIndex = 5 Top = 120 Width = 732 End End Begin MSFlexGridLib.MSFlexGrid GrdSheet Height = 1812 Left = 120 TabIndex = 2 Top = 1920 Width = 6612 _ExtentX = 11668 _ExtentY = 3201 _Version = 393216 Rows = 10 Cols = 10 BackColor = 12648447 ScrollTrack = -1 'True AllowUserResizing= 3 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin MSComDlg.CommonDialog dlgDlg Left = 0 Top = 1440 _ExtentX = 688 _ExtentY = 688 _Version = 393216 End Begin MSComctlLib.StatusBar sbStatusBar Align = 2 'Align Bottom Height = 270 Left = 0 TabIndex = 0 Top = 3795 Width = 8415 _ExtentX = 14843 _ExtentY = 476 _Version = 393216 BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} NumPanels = 3 BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} AutoSize = 1 Object.Width = 9208 Text = "Status" TextSave = "Status" EndProperty BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} Style = 6 AutoSize = 2 TextSave = "10/1/01" EndProperty BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} Style = 5 AutoSize = 2 TextSave = "11:43 AM" EndProperty EndProperty End Begin MSComctlLib.ImageList imlToolbarIcons Left = 3480 Top = 2880 _ExtentX = 794 _ExtentY = 794 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 16 MaskColor = 12632256 _Version = 393216 BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} NumListImages = 13 BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":112C Key = "New" EndProperty BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":123E Key = "Open" EndProperty BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1350 Key = "Save" EndProperty BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1462 Key = "Print" EndProperty BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1574 Key = "Cut" EndProperty BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1686 Key = "Copy" EndProperty BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1798 Key = "Paste" EndProperty BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":18AA Key = "Bold" EndProperty BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":19BC Key = "Italic" EndProperty BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1ACE Key = "Underline" EndProperty BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1BE0 Key = "Align Left" EndProperty BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1CF2 Key = "Center" EndProperty BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":1E04 Key = "Align Right" EndProperty EndProperty End Begin MSComctlLib.Toolbar tbToolBar Align = 1 'Align Top Height = 420 Left = 0 TabIndex = 1 Top = 0 Width = 8415 _ExtentX = 14843 _ExtentY = 741 ButtonWidth = 609 ButtonHeight = 582 Appearance = 1 ImageList = "imlToolbarIcons" _Version = 393216 BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} NumButtons = 17 BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "New" Object.ToolTipText = "New" ImageKey = "New" EndProperty BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Open" Object.ToolTipText = "Open" ImageKey = "Open" EndProperty BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Save" Object.ToolTipText = "Save" ImageKey = "Save" EndProperty BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Print" Object.ToolTipText = "Print" ImageKey = "Print" EndProperty BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Cut" Object.ToolTipText = "Cut" ImageKey = "Cut" EndProperty BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Copy" Object.ToolTipText = "Copy" ImageKey = "Copy" EndProperty BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Paste" Object.ToolTipText = "Paste to any application" ImageKey = "Paste" EndProperty BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Bold" Object.ToolTipText = "Bold" ImageKey = "Bold" Style = 1 EndProperty BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Italic" Object.ToolTipText = "Italic" ImageKey = "Italic" Style = 1 EndProperty BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Underline" Object.ToolTipText = "Underline" ImageKey = "Underline" Style = 1 EndProperty BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Align Left" Object.ToolTipText = "Align Left" ImageKey = "Align Left" Style = 2 EndProperty BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Center" Object.ToolTipText = "Center" ImageKey = "Center" Style = 2 EndProperty BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Align Right" Object.ToolTipText = "Align Right" ImageKey = "Align Right" Style = 2 EndProperty EndProperty Begin VB.TextBox txtDim Height = 288 Left = 5160 TabIndex = 12 Top = 0 Width = 2532 End End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuFileNew Caption = "&New" Shortcut = ^N End Begin VB.Menu mnuFileOpen Caption = "&Open..." Begin VB.Menu mnuText Caption = "Text file" End Begin VB.Menu mnuGrd Caption = "Grd File" End End Begin VB.Menu mnuFileClose Caption = "&Close" Visible = 0 'False End Begin VB.Menu mnuFileBar0 Caption = "-" End Begin VB.Menu mnuFileSave Caption = "&Save" Begin VB.Menu mnuSaveTxt Caption = "As Text" End Begin VB.Menu mnuSaveGrd Caption = "As Grd" End Begin VB.Menu mnuSaveExl Caption = "As Excel" End End Begin VB.Menu mnuFileSaveAs Caption = "Save &As..." Visible = 0 'False End Begin VB.Menu mnuFileSaveAll Caption = "Save A&ll" Visible = 0 'False End Begin VB.Menu mnuFileBar1 Caption = "-" End Begin VB.Menu mnuFileProperties Caption = "Propert&ies" Visible = 0 'False End Begin VB.Menu mnuFileBar2 Caption = "-" Visible = 0 'False End Begin VB.Menu mnuFilePageSetup Caption = "Page Set&up..." Visible = 0 'False End Begin VB.Menu mnuFilePrintPreview Caption = "Print Pre&view" Visible = 0 'False End Begin VB.Menu mnuFilePrint Caption = "&Print..." End Begin VB.Menu mnuFileBar3 Caption = "-" End Begin VB.Menu mnuFileSend Caption = "Sen&d..." Visible = 0 'False End Begin VB.Menu mnuFileBar4 Caption = "-" Visible = 0 'False End Begin VB.Menu mnuFileMRU Caption = "" Index = 1 Visible = 0 'False End Begin VB.Menu mnuFileMRU Caption = "" Index = 2 Visible = 0 'False End Begin VB.Menu mnuFileMRU Caption = "" Index = 3 Visible = 0 'False End Begin VB.Menu mnuFileBar5 Caption = "-" Visible = 0 'False End Begin VB.Menu mnuFileExit Caption = "E&xit" End End Begin VB.Menu mnuEdit Caption = "&Edit" Begin VB.Menu mnuEditUndo Caption = "&Undo" Visible = 0 'False End Begin VB.Menu mnuEditCut Caption = "Cu&t" Shortcut = ^X End Begin VB.Menu mnuEditCopy Caption = "&Copy" Shortcut = ^C End Begin VB.Menu mnuEditCopyFormula Caption = "Copy &Formula" End Begin VB.Menu mnuViewBar0 Caption = "-" End Begin VB.Menu mnuEditPaste Caption = "&Paste" Shortcut = ^V End Begin VB.Menu mnuEditPasteSpecial Caption = "Paste &Formula..." End Begin VB.Menu mnuEditBar0 Caption = "-" End Begin VB.Menu mnuResize Caption = "Resize &Sheet" End Begin VB.Menu mnuRowCol Caption = "&Rows && Cols" End End Begin VB.Menu mnuView Caption = "&View" Begin VB.Menu mnuViewToolbar Caption = "&Toolbar" Checked = -1 'True End Begin VB.Menu mnuViewStatusBar Caption = "Status &Bar" Checked = -1 'True End Begin VB.Menu mnuViewRefresh Caption = "&Refresh" Visible = 0 'False End Begin VB.Menu mnuViewWebBrowser Caption = "&Web Browser" Visible = 0 'False End End Begin VB.Menu mnuViewOptions Caption = "&Format " Begin VB.Menu mnuAutoFormat Caption = "&Auto Format" Checked = -1 'True End Begin VB.Menu mnuFormatCell Caption = "&Cell" End Begin VB.Menu mnuFormatRow Caption = "&Row" End Begin VB.Menu mnuFormatCol Caption = "&Col" End End Begin VB.Menu mnuHelp Caption = "&Help" Begin VB.Menu mnuHelpContents Caption = "&Contents" Visible = 0 'False End Begin VB.Menu mnuHelpSearchForHelpOn Caption = "&Search For Help On..." Shortcut = {F1} End Begin VB.Menu mnuHelpBar0 Caption = "-" Visible = 0 'False End Begin VB.Menu mnuHelpAbout Caption = "&About " End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim myExcelFile As New ExcelFile Dim formulaCopy Dim AutoForm As Boolean Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any) Private Sub cmbFonts_Click() GrdSheet.CellFontName = cmbFonts.Text GrdSheet.SetFocus End Sub Private Sub cmbFontSize_Click() GrdSheet.CellFontSize = cmbFontSize.Text GrdSheet.SetFocus End Sub Private Sub cmbFunc_Click() txt = "Syntax " Select Case UCase(cmbFunc.Text) Case "(" txt = "" Case "-" txt = "" Case "NOT" txt = txt + "Expression1= NOT Expression2" Case "," txt = "" Case ")" txt = "" Case "^" txt = txt + "num1 ^ num2" Case "*" txt = txt + "num1 * num2" Case "/" txt = txt + "num1 / num2" Case "\" txt = txt + " num1 \ num2 This is Integer division" Case "MOD" txt = txt + "num1 MOD num2" Case "+" txt = txt + "num1 + num2" Case "-" txt = txt + "num1 - num2" Case "=" txt = "" Case "<" txt = txt + "expression1 < expression2" Case "<=" txt = txt + "expression1 <= expression2" Case ">" txt = txt + "expression1 > expression2" Case ">=" txt = txt + "expression1 >= expression2" Case "<>" txt = txt + "expression1 <> expression2" Case "AND" txt = txt + "expression1 AND expression2 BOOLEAN" Case "OR" txt = txt + "expression1 OR expression2 BOOLEAN" Case "XOR" txt = txt + "expression1 XOR expression2 BOOLEAN" Case "PI" txt = "Insrts the value of PI= 3.14159265358979" Case "DEG" txt = txt + "DEG(num) RETURNS THE GEGREES IN num" Case "RAD" txt = txt + "RAD(num) RETURNS THE RADIANS IN num" Case "ABS" txt = txt + "ABS(num) Absolute value" Case "INT" txt = txt + "INT(num) Integer value" Case "FIX" Case "SGN" txt = txt + "SGN(num) Sign of num" Case "SQR" txt = txt + "SQR(num) Square root of +num" Case "LOG" txt = txt + "LOG(num) Common log of num" Case "LN" txt = txt + "DEG(num) Natural log of num num" Case "EXP" txt = txt + "exp(num)" Case "SIN" txt = txt + "SIN(num in radians)" Case "ASIN" txt = txt + "ASIN(num) returns the angle in radians" Case "COS" txt = txt + "COS(num in radians)" Case "ACOS" txt = txt + "ACOS(num) returns the angle in radians" Case "TAN" txt = txt + "TAN(num in radians)" Case "ATN" txt = txt + "ATN(num) returns the angle in radians" Case "ATAN" txt = txt + "ATN(num) returns the angle in radians" Case "SEC" txt = txt + "SEC(num in radians)" Case "CSC" txt = txt + "CSC(num in radians)" Case "COT" txt = txt + "COT(num in radians)" Case "SIN_D" txt = txt + "SIN_D(num in degrees)" Case "COS_D" txt = txt + "COS_D(num in degrees)" Case "TAN_D" txt = txt + "TAN_D(num in degrees)" Case "POWER" txt = txt + "(POWER(num1,num2) RETURNS num1 to power num2" Case "MIN", "MAX" txt = txt + "MAX/MIN (exp1,exp2)" Case "&" txt = txt + "String1 & string2" Case "LEN" txt = txt + "LEN(string) length of string" Case "ASC" txt = txt + "ASC(string) ASCII of first character of string)" Case "SPACE" txt = txt + "SPACE(num) insert num spaces" Case "LEFT", "RIGHT" txt = txt + "LEFT/RIGHT(string ,n) left/right n chars" Case "MID" txt = txt + "MID(string, start[, n] n chars from start)" Case "INSTR" txt = txt + "INSTR(string1,string2) location of string2 in string1" Case "GAMMA" txt = txt + "GAMMA(x) Returns the Gamma of x" Case "SINH" txt = txt + "SINH(x) Returns hyperbolic sine" Case "COSH" txt = txt + "COSH(x) Returns hyperbolic co-sine" Case "TANH" txt = txt + "TANH(x) Returns the hyperbolic Tan of x" Case "SUMABOVE" txt = txt + "Returns the sum of numerical values of the cells above" Case "ASINH" txt = txt + "ASINH(x) Returns Inverse Hyperbolic sine of x" Case "ACOSH" txt = txt + "ASINH(x) Returns Inverse Hyperbolic Co-sine of x" Case Else txt = "" End Select txtFormula.Text = txtFormula.Text + cmbFunc.Text cmbFunc.ToolTipText = txt End Sub Private Sub Command1_Click() GrdSheet.SetFocus On Error GoTo prnError Dim expr As New CExpression txt = Right(txtFormula, Len(txtFormula.Text) - 1) If UCase(txt) = "SUMABOVE" Then Thisrow = GrdSheet.row If Thisrow = GrdSheet.FixedRows Then txtFormula.Text = "" formula(GrdSheet.row, GrdSheet.col) = "" Exit Sub End If For i = Thisrow - 1 To GrdSheet.FixedRows Step -1 GrdSheet.row = i Sum = Sum + Val(GrdSheet) Next GrdSheet.row = Thisrow GrdSheet = Sum Exit Sub End If If Len(txt) > 200 Then MsgBox "Expression cannot have more than 200 characters" Exit Sub End If expr.Expression = txt If expr.ErrorCode Then MsgBox "Error in expression" Exit Sub End If Command1.Enabled = False Command2.Enabled = False GrdSheet = expr.Value(txt) Exit Sub prnError: GrdSheet = "" MsgBox "Error in expression" Err.Clear End Sub Private Sub Command2_Click() txtFormula.Text = "" formula(GrdSheet.row, GrdSheet.col) = "" 'GrdSheet = "" End Sub Private Sub Form_Load() Dim Fot As Integer ReDim formula(GrdSheet.Rows - 1, GrdSheet.Cols - 1) ReDim GridArray(GrdSheet.Rows - 1, GrdSheet.Cols - 1) 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) LabelGrdSheet GrdSheet.row = 2: GrdSheet.col = 1: GrdSheet.row = 1 txtDim.Enabled = True txtDim.Text = "Rows=" & Str(GrdSheet.Rows) & " : Cols=" & Str(GrdSheet.Cols) txtDim.Enabled = False Fot = Screen.FontCount - 1 For i = 1 To Fot ' - 1 cmbFonts.AddItem Screen.Fonts(i) Next For i = 6 To 30 Step 2 cmbFontSize.AddItem i Next cmbFunc.AddItem "(" cmbFunc.AddItem "-" cmbFunc.AddItem "NOT" cmbFunc.AddItem "," cmbFunc.AddItem ")" cmbFunc.AddItem "^" cmbFunc.AddItem "*" cmbFunc.AddItem "/" cmbFunc.AddItem "\" cmbFunc.AddItem "MOD" cmbFunc.AddItem "+" cmbFunc.AddItem "-" cmbFunc.AddItem "=" cmbFunc.AddItem "<" cmbFunc.AddItem "<=" cmbFunc.AddItem ">" cmbFunc.AddItem ">=" cmbFunc.AddItem "<>" cmbFunc.AddItem "AND" cmbFunc.AddItem "OR" cmbFunc.AddItem "XOR" cmbFunc.AddItem "PI" cmbFunc.AddItem "DEG" cmbFunc.AddItem "RAD" cmbFunc.AddItem "ABS" cmbFunc.AddItem "INT" cmbFunc.AddItem "FIX" cmbFunc.AddItem "SGN" cmbFunc.AddItem "SQR" cmbFunc.AddItem "LOG" cmbFunc.AddItem "LN" cmbFunc.AddItem "EXP" cmbFunc.AddItem "SIN" cmbFunc.AddItem "ASIN" cmbFunc.AddItem "COS" cmbFunc.AddItem "ACOS" cmbFunc.AddItem "TAN" cmbFunc.AddItem "ATN" cmbFunc.AddItem "ATAN" cmbFunc.AddItem "SEC" cmbFunc.AddItem "CSC" cmbFunc.AddItem "COT" cmbFunc.AddItem "SIN_D" cmbFunc.AddItem "COS_D" cmbFunc.AddItem "TAN_D" cmbFunc.AddItem "POWER" cmbFunc.AddItem "MIN" cmbFunc.AddItem "MAX" cmbFunc.AddItem "LEN" cmbFunc.AddItem "ASC" cmbFunc.AddItem "SPACE" cmbFunc.AddItem "STRING" cmbFunc.AddItem "LEFT" cmbFunc.AddItem "RIGHT" cmbFunc.AddItem "MID" cmbFunc.AddItem "INSTR" cmbFunc.AddItem "&" cmbFunc.AddItem "GAMMA" cmbFunc.AddItem "SINH" cmbFunc.AddItem "COSH" cmbFunc.AddItem "TANH" cmbFunc.AddItem "SUMABOVE" cmbFunc.AddItem "ASINH" cmbFunc.AddItem "ACOSH" cmbFunc.Text = "=" AutoForm = True End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single) If Button = vbRightButton Then PopupMenu mnuEdit End If End Sub Private Sub Form_Resize() Frame.Move 0, tbToolBar.Height Frame.Width = ScaleWidth GrdSheet.Move (Width - GrdSheet.Width) / 2, tbToolBar.Height + Frame.Height + frFonts.Height End Sub Private Sub Form_Unload(Cancel As Integer) For i = Forms.Count - 1 To 1 Step -1 Unload Forms(i) Next 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 End Sub Private Sub mnuAutoFormat_Click() AutoForm = Not AutoForm End Sub Private Sub mnuEditCopyFormula_Click() formulaCopy = formula(GrdSheet.row, GrdSheet.col) mnuEditPasteSpecial.Enabled = True End Sub Private Sub mnuFormatCell_Click() txt = InputBox("Please enter a format string eg. #0.0#" + vbCrLf + "any number of place holders # and 0 can be entered" + vbCrLf + "Other characters are also permissible") If txt = "" Then Exit Sub End If GrdSheet.Text = Format(Val(GrdSheet.Text), txt) End Sub Private Sub mnuFormatCol_Click() frmFormat.Frame2.Visible = True frmFormat.Caption = "Format Col width" frmFormat.Text2.Text = GrdSheet.COLWIDTH(GrdSheet.col) frmFormat.Show vbModal End Sub Private Sub mnuFormatRow_Click() frmFormat.Frame1.Visible = True frmFormat.Caption = "Format Row" frmFormat.Text1.Text = GrdSheet.RowHeight(GrdSheet.row) frmFormat.Show vbModal End Sub Private Sub mnuGrd_Click() mnuFileNew_Click GrdSheet.Clear With dlgDlg .DialogTitle = "Open" .CancelError = False .FileName = "" 'ToDo: set the flags and attributes of the common dialog control .Filter = "Grd Files (*.grd)|*.grd" .ShowOpen If Len(.FileName) = 0 Then Exit Sub End If sfile = .FileName End With OpenGrd sfile LabelGrdSheet GrdSheet.row = 1: GrdSheet.col = 1 End Sub Private Sub mnuResize_Click() NewCols = GrdSheet.Width NewRows = GrdSheet.Height frmOption.lblCols.Caption = "Height" frmOption.lblRows.Caption = "Width" frmOption.txtCols.Text = GrdSheet.Height frmOption.txtRows.Text = GrdSheet.Width frmOption.Show vbModal If Cancel = True Then Cancel = False Exit Sub End If GrdSheet.Width = NewRows If GrdSheet.Height >= ScaleWidth Then GrdSheet.Height = ScaleWidth Else GrdSheet.Height = NewCols End If GrdSheet.Move (Width - GrdSheet.Width) / 2, tbToolBar.Height + Frame.Height + frFonts.Height GrdSheet.row = 1: GrdSheet.col = 1 End Sub Private Sub mnuRowCol_Click() On Local Error Resume Next NewCols = GrdSheet.Cols NewRows = GrdSheet.Rows frmOption.lblCols.Caption = "Cols" frmOption.lblRows.Caption = "Rows" frmOption.txtCols.Text = GrdSheet.Cols frmOption.txtRows.Text = GrdSheet.Rows frmOption.Show vbModal If Cancel = True Then Cancel = False Exit Sub End If If NewRows > 101 Or NewCols > 101 Then End If ReDim tempdata(GrdSheet.Rows - 1, GrdSheet.Cols - 1) ReDim tempformula(GrdSheet.Rows - 1, GrdSheet.Cols - 1) For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 tempdata(i, j) = GridArray(i, j) tempformula(i, j) = formula(i, j) Next: Next With GrdSheet .Rows = NewRows .Cols = NewCols End With ReDim GridArray(NewRows - 1, NewCols - 1) ReDim formula(GrdSheet.Rows - 1, GrdSheet.Cols - 1) For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 GridArray(i, j) = tempdata(i, j) formula(i, j) = tempformula(i, j) Next: Next txtDim.Enabled = True txtDim.Text = "Rows=" & Str(GrdSheet.Rows) & " : Cols=" & Str(GrdSheet.Cols) txtDim.Enabled = False LabelGrdSheet GrdSheet.row = 1: GrdSheet.col = 1 End Sub Private Sub mnuSaveExL_Click() Dim irow As Long, icol As Long With dlgDlg .DialogTitle = "Save as Excel" .FileName = "" .CancelError = False .Filter = "Text Files (*.xls)|*.xls" .ShowSave If Len(.FileName) = 0 Then Exit Sub End If sfile = .FileName End With If InStr(sfile, ".xls") = 0 Then sfile = sfil & ".xls" End If With myExcelFile FileName$ = sfile .CreateFile FileName$ 'set a Password for the file. If set, the rest of the spreadsheet will 'be encrypted. If a password is used it must immediately follow the 'CreateFile method. 'This is different then protecting the spreadsheet (see below). 'NOTE: For some reason this function does not work. Excel will 'recognize that the file is password protected, but entering the password 'will not work. Also, the file is not encrypted. Therefore, do not use 'this function until I can figure out why it doesn't work. There is not 'much documentation on this function available. '.SetFilePassword "PAUL" 'specify whether to print the gridlines or not 'this should come before the setting of fonts and margins .PrintGridLines = False 'it is a good idea to set margins, fonts and column widths 'prior to writing any text/numerics to the spreadsheet. These 'should come before setting the fonts. ' .SetMargin xlsTopMargin, 1.5 'set to 1.5 inches ' .SetMargin xlsLeftMargin, 1.5 ' .SetMargin xlsRightMargin, 1.5 ' .SetMargin xlsBottomMargin, 1.5 'to insert a Horizontal Page Break you need to specify the row just 'after where you want the page break to occur. You can insert as many 'page breaks as you wish (in any order). ' .InsertHorizPageBreak 10 '.InsertHorizPageBreak 20 'Up to 4 fonts can be specified for the spreadsheet. This is a 'limitation of the Excel 2.1 format. For each value written to the 'spreadsheet you can specify which font to use. .SetFont "Arial", 10, xlsNoFormat 'font0 .SetFont "Arial", 10, xlsBold 'font1 .SetFont "Arial", 10, xlsBold + xlsUnderline 'font2 .SetFont "Courier", 12, xlsItalic 'font3 'Column widths are specified in Excel as 1/256th of a character. '.SetColumnWidth 1, 5, 18 'set any header or footer that you want to print on 'every page. This text will be centered at the top and/or 'bottom of each page. The font will always be the font that 'is specified as font0, therefore you should only set the 'header/footer after specifying the fonts through SetFont. '.SetHeader "This is the header" '.SetFooter "This is the footer" 'write some data to the spreadsheet 'Use the default format #3 "#,##0" (refer to the WriteDefaultFormats function) 'The WriteDefaultFormats function is compliments of Dieter Hauk in Germany. '.WriteValue xlsInteger, xlsFont0, xlsLeftAlign, xlsNormal, 6, 1, 2000, 3 'write a cell with a shaded number with a bottom border '.WriteValue xlsNumber, xlsFont1, xlsrightAlign + xlsBottomBorder + xlsShaded, xlsNormal, 7, 1, 12123.456, 4 'write a normal left aligned string using font2 (bold & underline) For irow = 1 To GrdSheet.Rows - 1 GrdSheet.row = irow For icol = 1 To GrdSheet.Cols - 1 GrdSheet.col = icol .SetFont GrdSheet.CellFontName, 10, xlsNoFormat .WriteValue xlsText, xlsFont0, xlsLeftAlign, xlsNormal, irow, icol, GrdSheet.Text If formula(GrdSheet.row, GrdSheet.col) > "" Then .WriteValue xlsText, xlsFont0, xlsCentreAlign, xlsHidden, irow, icol, formula(GrdSheet.row, GrdSheet.col) End If 'write a locked cell. The cell will not be able to be overwritten, BUT you 'must set the sheet PROTECTION to on before it will take effect!!! '.WriteValue xlsText, xlsFont3, xlsLeftAlign, xlsLocked, 9, 1, "This cell is locked" 'fill the cell with "F"'s '.WriteValue xlsText, xlsFont0, xlsFillCell, xlsNormal, 10, 1, "F" 'write a hidden cell to the spreadsheet. This only works for cells 'that contain formulae. Text, Number, Integer value text can not be hidden 'using this feature. It is included here for the sake of completeness. '.WriteValue xlsText, xlsFont0, xlsCentreAlign, xlsHidden, 11, 1, "If this were a formula it would be hidden!" 'Dim d As Date 'd = "2001/01/15" '.WriteValue xlsText, xlsFont0, xlsCentreAlign, xlsNormal, 15, 1, d, 12 'PROTECT the spreadsheet so any cells specified as LOCKED will not be 'overwritten. Also, all cells with HIDDEN set will hide their formulae. 'PROTECT does not use a password. '.ProtectSpreadsheet = True 'Finally, close the spreadsheet .CloseFile Close End With Close MsgBox "Excel BIFF Spreadsheet created." & vbCrLf & "Filename: " & FileName$, vbInformation + vbOKOnly, "Excel Class" End Sub Private Sub mnuSaveGrd_Click() With dlgDlg .DialogTitle = "Save" .FileName = "" .CancelError = False .Filter = "Grd Files (*.grd)|*.grd" .ShowSave If Len(.FileName) = 0 Then Exit Sub End If sfile = .FileName End With SaveGrd sfile End Sub Private Sub mnuSaveTxt_Click() With dlgDlg .DialogTitle = "Save as Text" .FileName = "" .CancelError = False .Filter = "Text Files (*.dat)|*.dat" .ShowSave If Len(.FileName) = 0 Then Exit Sub End If sfile = .FileName End With SaveText sfile GrdSheet.row = 1: GrdSheet.col = 1 End Sub Private Sub mnuText_Click() With dlgDlg .DialogTitle = "Open" .FileName = "" .CancelError = False .Filter = "Text Files (*.dat)|*.dat" .ShowOpen If Len(.FileName) = 0 Then Exit Sub End If sfile = .FileName End With OpenText sfile GrdSheet.row = 1: GrdSheet.col = 1 LabelGrdSheet End Sub Private Sub GrdSheet_DblClick() If txtFormula.Text = "" Then txtFormula.Text = "=" txtFormula.SelStart = 1 End If txtFormula.SetFocus End Sub Private Sub GrdSheet_EnterCell() If GrdSheet.col = 0 Or GrdSheet.row = 0 Then Exit Sub End If cmbFontSize.Text = GrdSheet.CellFontSize cmbFonts.Text = GrdSheet.CellFontName If GrdSheet.CellFontUnderline = True Then tbToolBar.Buttons.Item(13).Value = tbrPressed tbToolBar.Buttons.Item(13).Value = tbrUnpressed End If If GrdSheet.CellFontBold = True Then tbToolBar.Buttons.Item(11).Value = tbrPressed tbToolBar.Buttons.Item(11).Value = tbrUnpressed End If If GrdSheet.CellFontItalic = True Then tbToolBar.Buttons.Item(12).Value = tbrPressed tbToolBar.Buttons.Item(12).Value = tbrUnpressed End If GrdSheet.CellBackColor = QBColor(15) txtRowCol = Str(GrdSheet.row) + " : " + Str(GrdSheet.col) GridArray(GrdSheet.row, GrdSheet.col) = GrdSheet.Text txtCellVal.Text = GrdSheet txtFormula = formula(GrdSheet.row, GrdSheet.col) If txtFormula = "" Then Command1.Enabled = False Command2.Enabled = False End If Select Case GrdSheet.CellAlignment Case 2 tbToolBar.Buttons.Item(15).Value = tbrUnpressed tbToolBar.Buttons.Item(16).Value = tbrUnpressed tbToolBar.Buttons.Item(17).Value = tbrUnpressed tbToolBar.Buttons.Item(15).Value = tbrPressed Case 3 tbToolBar.Buttons.Item(15).Value = tbrUnpressed tbToolBar.Buttons.Item(16).Value = tbrUnpressed tbToolBar.Buttons.Item(17).Value = tbrUnpressed tbToolBar.Buttons.Item(16).Value = tbrPressed Case 6 tbToolBar.Buttons.Item(17).Value = tbrPressed tbToolBar.Buttons.Item(15).Value = tbrUnpressed tbToolBar.Buttons.Item(16).Value = tbrUnpressed Case Else tbToolBar.Buttons.Item(15).Value = tbrUnpressed tbToolBar.Buttons.Item(16).Value = tbrUnpressed tbToolBar.Buttons.Item(17).Value = tbrUnpressed End Select End Sub Private Sub GrdSheet_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 13, 27 KeyAscii = 0 Case 8 GrdSheet.Text = Left(GrdSheet.Text, Len(GrdSheet.Text) - 1) Case Else GrdSheet.Text = GrdSheet.Text + Chr(KeyAscii) End Select txtCellVal.Text = GrdSheet.Text End Sub Private Sub GrdSheet_LeaveCell() If GrdSheet.col = 0 Or GrdSheet.row = 0 Then Exit Sub End If GrdSheet.CellBackColor = &HC0FFFF GridArray(GrdSheet.row, GrdSheet.col) = GrdSheet.Text formula(GrdSheet.row, GrdSheet.col) = txtFormula.Text If GrdSheet.COLWIDTH(GrdSheet.col) < 12.5 * Len(GrdSheet.Text) * GrdSheet.CellFontSize Then GrdSheet.COLWIDTH(GrdSheet.col) = 12.5 * Len(GrdSheet.Text) * GrdSheet.CellFontSize End If If GrdSheet.RowHeight(GrdSheet.row) < 29 * GrdSheet.CellFontSize Then GrdSheet.RowHeight(GrdSheet.row) = 29 * GrdSheet.CellFontSize End If End Sub Private Sub GrdSheet_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single) If Button = vbRightButton Then PopupMenu mnuEdit End If End Sub Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "New" 'ToDo: Add 'New' button code. mnuFileNew_Click Case "Open" 'mnuFileOpen_Click Case "Save" Case "Print" mnuFilePrint_Click Case "Cut" mnuEditCut_Click Case "Copy" mnuEditCopy_Click Case "Paste" mnuEditPaste_Click Case "Bold" Bold Case "Italic" italic Case "Underline" UnderLine Case "Align Left" GrdSheet.CellAlignment = 2 Case "Center" GrdSheet.CellAlignment = 3 Case "Align Right" GrdSheet.CellAlignment = 6 End Select End Sub Private Sub mnuHelpAbout_Click() MsgBox "Version " & App.Major & "." & App.Minor & "." & App.Revision End Sub Private Sub mnuHelpSearchForHelpOn_Click() Dim nRet As Integer frmBrowser.Show vbModal End Sub Private Sub mnuHelpContents_Click() Dim nRet As Integer 'if there is no helpfile for this project display a message to the user 'you can set the HelpFile for your application in the 'Project Properties dialog If Len(App.HelpFile) = 0 Then MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption Else On Error Resume Next nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0) If Err Then MsgBox Err.Description End If End If End Sub Private Sub mnuViewOptions_Click() mnuAutoFormat.Checked = AutoForm 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 Private Sub mnuEditPasteSpecial_Click() formula(GrdSheet.row, GrdSheet.col) = formulaCopy frmMain.txtFormula.Text = formulaCopy Command1_Click mnuEditPasteSpecial.Enabled = False End Sub Private Sub mnuEditPaste_Click() CurrCol = GrdSheet.col currRow = GrdSheet.row CutText = Trim(Clipboard.GetText) GrdSheet.Clip = Clipboard.GetText GrdSheet.col = 1: GrdSheet.row = 1 For i = currRow To currRow '+ R GrdSheet.row = i For j = CurrCol To CurrCol '+ C GrdSheet.col = j Next Next GrdSheet.row = currRow: GrdSheet.col = CurrCol RefreshData GrdSheet.row = 1: GrdSheet.col = 1 End Sub Private Sub mnuEditCopy_Click() Clipboard.Clear Clipboard.SetText GrdSheet.Clip End Sub Private Sub mnuEditCut_Click() Clipboard.SetText GrdSheet.Clip Cut End Sub Private Sub mnuEditUndo_Click() MsgBox "Add 'mnuEditUndo_Click' code." End Sub Private Sub mnuFileExit_Click() Unload Me End Sub Private Sub mnuFileSend_Click() MsgBox "Add 'mnuFileSend_Click' code." End Sub Private Sub mnuFilePrint_Click() dlgDlg.DialogTitle = "Print" dlgDlg.ShowPrinter For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 txt = txt + GridArray(i, j) + vbTab Next txt = txt + vbCrLf Next Clipboard.SetText txt Printer.Print txt Printer.EndDoc End Sub Private Sub mnuFilePrintPreview_Click() MsgBox "Add 'mnuFilePrintPreview_Click' code." End Sub Private Sub mnuFilePageSetup_Click() On Error Resume Next With dlgDlg .DialogTitle = "Page Setup" .CancelError = True .ShowPrinter End With End Sub Private Sub mnuFileProperties_Click() MsgBox "Add 'mnuFileProperties_Click' code." End Sub Private Sub mnuFileSaveAll_Click() MsgBox "Add 'mnuFileSaveAll_Click' code." End Sub Private Sub mnuFileSaveAs_Click() MsgBox "Add 'mnuFileSaveAs_Click' code." End Sub Private Sub mnuFileClose_Click() MsgBox "Add 'mnuFileClose_Click' code." End Sub Private Sub mnuFileNew_Click() ReDim GridArray(10, 10) ReDim formula(10, 10) With GrdSheet ReDim formula(10, 10) .Clear .Rows = 10 .Cols = 10 For i = 1 To .Rows - 1 .row = i For j = 1 To .Cols - 1 .col = j GrdSheet = "": formula(i, j) = "" Next Next End With ReDim GridArray(10, 10) ReDim formula(10, 10) GrdSheet.Clear formula(1, 1) = "" ReDim formula(10, 10) LabelGrdSheet GrdSheet.row = 1 GrdSheet.col = 1 End Sub Sub LabelGrdSheet() GrdSheet.CellAlignment = flexAlignCenterCenter '4 With GrdSheet .row = 0 For i = .FixedCols To .Cols - 1 .col = i .COLWIDTH(.col) = 912 GrdSheet.CellFontBold = True .Text = Str(i) Next .col = 0 For i = .FixedRows To .Rows - 1 .row = i .RowHeight(.row) = 228 GrdSheet.CellFontBold = True .Text = Str(i) Next .row = 1 .col = 1 End With End Sub Sub Bold() Rs = GrdSheet.RowSel Cs = GrdSheet.ColSel rr = GrdSheet.row cc = GrdSheet.col If tbToolBar.Buttons.Item(11).Value = tbrPressed Then PressB = True PressB = False End If For ro = rr To GrdSheet.RowSel 'If Selected for the Top Left For co = cc To GrdSheet.ColSel GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontBold = PressB Next co Next ro For ro = GrdSheet.row To GrdSheet.RowSel Step -1 'If Selected for the Top Right For co = GrdSheet.col To GrdSheet.ColSel Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontBold = PressB Next co Next ro For ro = GrdSheet.RowSel To GrdSheet.row Step -1 'If Selected for the Bottom Left For co = GrdSheet.col To GrdSheet.ColSel Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontBold = PressB Next co Next ro For ro = GrdSheet.row To GrdSheet.RowSel Step -1 'If Selected for the Bottom Right For co = GrdSheet.ColSel To GrdSheet.col Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontBold = PressB Next co Next ro GrdSheet.row = rr GrdSheet.col = cc GrdSheet.RowSel = Rs GrdSheet.ColSel = Cs Exit Sub last: End Sub Sub italic() 'Dim rr, cc, Rs, Cs, ro, co rr = GrdSheet.row cc = GrdSheet.col Rs = GrdSheet.RowSel Cs = GrdSheet.ColSel If tbToolBar.Buttons.Item(12).Value = tbrPressed Then PressI = True PressI = False End If For ro = rr To GrdSheet.RowSel 'If Selected for the Top Left For co = cc To GrdSheet.ColSel GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontItalic = PressI Next co Next ro For ro = rr To GrdSheet.RowSel Step -1 'If Selected for the Top Right For co = cc To GrdSheet.ColSel Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontItalic = PressI Next co Next ro For ro = rr To GrdSheet.row Step -1 'If Selected for the Bottom Left For co = cc To GrdSheet.ColSel Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontItalic = PressI Next co Next ro For ro = rr To GrdSheet.RowSel Step -1 'If Selected for the Bottom Right For co = cc To GrdSheet.col Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontItalic = PressI Next co Next ro GrdSheet.row = rr GrdSheet.col = cc GrdSheet.RowSel = Rs GrdSheet.ColSel = Cs End Sub Sub UnderLine() rr = GrdSheet.row cc = GrdSheet.col Rs = GrdSheet.RowSel Cs = GrdSheet.ColSel If tbToolBar.Buttons.Item(13).Value = tbrPressed Then PressU = True PressU = False End If For ro = rr To GrdSheet.RowSel 'If Selected for the Top Left For co = cc To GrdSheet.ColSel GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontUnderline = PressU Next co Next ro For ro = rr To GrdSheet.RowSel Step -1 'If Selected for the Top Right For co = cc To GrdSheet.ColSel Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontUnderline = PressU Next co Next ro For ro = rr To GrdSheet.row Step -1 'If Selected for the Bottom Left For co = cc To GrdSheet.ColSel Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontUnderline = PressU Next co Next ro For ro = rr To GrdSheet.RowSel Step -1 'If Selected for the Bottom Right For co = cc To GrdSheet.col Step -1 GrdSheet.row = ro GrdSheet.col = co GrdSheet.CellFontUnderline = PressU Next co Next ro GrdSheet.row = rr GrdSheet.col = cc GrdSheet.RowSel = Rs GrdSheet.ColSel = Cs End Sub Sub OpenText(f) Close On Local Error GoTo ErrorText GrdSheet.Rows = 1: GrdSheet.Cols = 1 GrdSheet.Clear n = FreeFile Open f For Input As #n With GrdSheet Input #n, i .Rows = i Input #n, j .Cols = j ReDim GridArray(i - 1, j - 1) ReDim formula(i - 1, j - 1) For i = 1 To .Rows - 1 .row = i For j = 1 To .Cols - 1 .col = j Line Input #n, Text .Text = Text For i = 1 To .Rows - 1 For j = 1 To .Cols - 1 End With Close Exit Sub ErrorText: Close MsgBox "Error in file" mnuFileNew_Click End Sub Sub SaveText(f) Close n = FreeFile Open f For Output As #n Print #n, GrdSheet.Rows, GrdSheet.Cols For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 Print #n, GridArray(i, j) Close n End Sub Private Sub txtFormula_Change() If Left(txtFormula.Text, 1) = "=" Then Command1.Enabled = True Command2.Enabled = True End If End Sub Sub RefreshData() With GrdSheet ReDim GridArray(.Rows - 1, .Cols - 1) For i = 1 To .Rows - 1 .row = i For j = 1 To .Cols - 1 .col = j GridArray(i, j) = .Text End With Rowss = GrdSheet.Rows Colss = GrdSheet.Cols ReDim temp(Rowss - 1, Colss - 1) For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 temp(i, j) = formula(i, j) For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 formula(i, j) = temp(i, j) End Sub Sub SaveGrd(f) n = FreeFile Open f For Output As #n With GrdSheet Print #n, .Rows, .Cols For i = 1 To .Rows - 1 .row = i For j = 1 To .Cols - 1 .col = j Write #n, .Text Print #n, formula(i, j) Write #n, .CellAlignment Write #n, .CellFontBold Write #n, .CellFontItalic Write #n, .CellFontUnderline Print #n, formula(i, j) End With For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 Write #n, GridArray(i, j) Print #n, formula(i, j) Close n End Sub Sub OpenGrd(f) On Error GoTo ErrorGrd GrdSheet.Rows = 1: GrdSheet.Cols = 1 GrdSheet.Clear n = FreeFile Open f For Input As #n With GrdSheet Input #n, Rowss, Colss .Rows = Rowss: .Cols = Colss ReDim GridArray(Rowss - 1, Colss - 1), formula(Rowss - 1, Colss - 1) For i = 1 To .Rows - 1 .row = i For j = 1 To .Cols - 1 .col = j Input #n, Text .Text = Text GridArray(i, j) = .Text Line Input #n, formula(i, j) Input #n, CellAlign .CellAlignment = CellAlign Input #n, CellFontBold .CellFontBold = CellFontBold Input #n, CellFontItalic .CellFontItalic = CellFontItalic Input #n, CellFontUnderline .CellFontUnderline = CellFontUnderline Line Input #n, formula(i, j) End With For i = 1 To GrdSheet.Rows - 1 For j = 1 To GrdSheet.Cols - 1 Input #n, GridArray(i, j) Line Input #n, formula(i, j) Close n Exit Sub ErrorGrd: Close n MsgBox "Error in file" mnuFileNew_Click End Sub Sub Cut() BR1 = GrdSheet.row BC1 = GrdSheet.col SelRow1 = GrdSheet.RowSel SelCol1 = GrdSheet.ColSel For ro = BR1 To SelRow1 For co = BC1 To SelCol1 GrdSheet.TextMatrix(ro, co) = "" Next co Next ro For ro = BR1 To SelRow1 Step -1 For co = BC1 To SelCol1 Step -1 GrdSheet.TextMatrix(ro, co) = "" Next co Next ro For ro = SelRow1 To BR1 Step -1 For co = BC1 To SelCol1 Step -1 GrdSheet.TextMatrix(ro, co) = "" Next co Next ro For ro = BR1 To SelRow1 Step -1 For co = SelCol1 To BC1 Step -1 GrdSheet.TextMatrix(ro, co) = "" Next co Next ro End Sub