Skip to main content

Content Starts Here

Read SpreadSheet control data

Article

Control version: FarPoint SpreadSheet 8

Sample Application:<FarPoint Technologies>\Spread 8\Samples\ActiveX\VB6\Sort\

The script below obtains the value of the specified cell in the SpreadSheet control and sets a new value.

VBScript

Sub GetSetValueInGridMain
  Dim wGrid, rowId, colId, value
  Set wGrid = Sys.Process("Project1").VBObject("Form1").VBObject("fpSpread1")
  rowId = 3' Or rowId = 4
  colId = 2' Or colId = 4
  value = GetTextValue(wGrid, rowId, colId)
  Log.Message "The [" & rowId & ", " & colId & "] cell value is " & value
  value = "05/05/2005"' Or value = "<new value>"
  If SetTextValue(wGrid, rowId, colId, value) Then
    Log.Message "The new [" & rowId & ", " & colId & "] cell value is " &_
                 GetTextValue(wGrid, rowId, colId)  
  End If
End Sub

Function GetTextValue(wGrid, rowId, colId)
  Dim tempValue 
  If Not rangeRight(wGrid, rowId, colId) Then
    Exit Function
  End If
  Call wGrid.GetText(colId, rowId, tempValue)
  GetTextValue = tempValue
End Function

Function SetTextValue(wGrid, rowId, colId, value)
  SetTextValue = False
  If Not rangeRight(wGrid, rowId, colId) Then
    Exit Function
  End If
  Call wGrid.SetText(colId, rowId, value)
  SetTextValue = True
End Function

Function rangeRight(wGrid, rowId, colId)
  Dim rowCount, colCount
  rangeRight = False
  rowCount = wGrid.Row
  colCount = wGrid.Col
  If rowId < 1 Or rowId > rowCount Or colId < 1 Or colId > colCount Then
    Log.Error "The [" & rowId & ", " & colId & "] cell doesn't exist."
    Exit Function
  End If
  rangeRight = True 
End Function
Previous MonthNext Month
SunMonTueWedThuFriSat