Thank you Ken, I've figured this out now.
I have another issue: can soneone tell me how to create a loop for declaring the inputdatasets - i have a user form whereby the user selects the importance of the raster in question in terms of their decision making (i.e. by ticking a checkbox), a raster may be selected as 'no importance' - in which case, I do not want it to be included within the mathop. How can I write the code to include a loop for this?
**************************
Private Sub CommandButton50_Click()
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pMap As IMap
Set pMap = pMxDoc.FocusMap
Dim pWSFact As IWorkspaceFactory
Set pWSFact = New AccessWorkspaceFactory
Dim pWS2 As IRasterWorkspaceEx
Set pWS2 = pWSFact.OpenFromFile(databasepath.Caption, 0)
Dim pWSF As IWorkspaceFactory
Set pWSF = New RasterWorkspaceFactory
Set pWS = pWSF.OpenFromFile("F:\PhD\GIS\Temp", 0)
'Create the MathOps object
Dim pMathOp As IMathOp
Set pMathOp = New RasterMathOps
'*****
If Eh.Value = True Then
Set pinputdataset = pWS2.OpenRasterDataset("elderlyh")
ElseIf Eh.Value = False Then
End If
If Em.Value = True Then
Set pinputdataset = pWS2.OpenRasterDataset("elderlym")
ElseIf Em.Value = False Then
End If
If El.Value = True Then
Set pinputdataset = pWS2.OpenRasterDataset("elderly")
End If
'declare input dataset2
If Lh.Value = True Then
Dim pInputDataset2 As IRasterDataset
Set pInputDataset2 = pWS2.OpenRasterDataset("parenth")
ElseIf Lh.Value = False Then
End If
If Lm.Value = True Then
Set pInputDataset2 = pWS2.OpenRasterDataset("parentm")
ElseIf Lm.Value = False Then
End If
If Lo.Value = True Then
Set pInputDataset2 = pWS2.OpenRasterDataset("parent")
End If
'declare input dataset3
If Vh.Value = True Then
Dim pInputDataset3 As IRasterDataset
Set pInputDataset3 = pWS2.OpenRasterDataset("carh")
ElseIf Vh.Value = False Then
End If
If Vm.Value = True Then
Set pInputDataset3 = pWS2.OpenRasterDataset("carm")
ElseIf Vm.Value = False Then
End If
If Vl.Value = True Then
Set pInputDataset3 = pWS2.OpenRasterDataset("car")
End If
'Set output workspace
Dim pEnv As IRasterAnalysisEnvironment
Set pEnv = pMathOp
Set pEnv.OutWorkspace = pWS
Dim pOutRaster As IRaster
Dim pOutRaster2 As IRaster
Set pOutRaster = pMathOp.Times(pinputdataset1, pInputDataset2)
Set pOutRaster2 = pMathOp.Times(pOutRaster, pInputDataset3)
'Create a raster layer and add it into ArcMap
Dim pOutRasLayer As IRasterLayer
Set pOutRasLayer = New RasterLayer
pOutRasLayer.CreateFromRaster pOutRaster2
pOutRasLayer.name = "VulnScore"
pMap.AddLayer pOutRasLayer