Cell contents

Post your questions, bug reports and suggestions here for BasicMaker 2016 for Windows.

Moderator: SoftMaker Team

Post Reply
SteveF48
Posts: 20
Joined: Thu Jul 11, 2013 11:32 am
Location: Deal, Kent, UK

Cell contents

Post by SteveF48 » Tue Aug 02, 2016 5:41 pm

Does Basicmaker treat all cell values as strings?
This statement concatenates the values in the two cells addded:
workRange.Cells(i, 11).Value = workRange.Cells(i, 11).Value + workRange.cells(c, 2).Value

i.e. 0 + 25 = 25, but 25 + 50 = 2550
The funny thing is that larger values are shown as e.g.5.02525E+015

I guess that I have to convert the cell contents to integers before adding them, even though the cells are formatted as numbers in PlanMaker
Thanks in advance,
Steve

SteveF48
Posts: 20
Joined: Thu Jul 11, 2013 11:32 am
Location: Deal, Kent, UK

Re: Cell contents

Post by SteveF48 » Tue Aug 02, 2016 6:06 pm

Yes it seems that all cell values have to be converted to numbers before being used for arithmetic, so + is identical to & it concatenates strings.

The script now works as expected
Thanks in advance,
Steve

martin-k
SoftMaker Team
SoftMaker Team
Posts: 2919
Joined: Fri Nov 21, 2003 4:57 pm
Location: Nürnberg, Germany
Contact:

Re: Cell contents

Post by martin-k » Wed Aug 03, 2016 9:00 am

The type depends on how you declare the variables that receive the contents. Example:

Code: Select all

sub test
	dim pm as object
	dim n as integer ' an integer, VarType will return 2 (integer)
	dim v ' a variant, VarType will return 8 (string)

	set pm = CreateObject("PlanMaker.Application")
	pm.Activate
	pm.Visible = True
	pm.Workbooks.Add

	pm.ActiveSheet.Range("A1").Value = 42

	n = pm.ActiveSheet.Range("A1").Value
	print n, VarType(n) ' this way you retrieve to an integer variable, result is an integer

	v = pm.ActiveSheet.Range("A1").Value
	print v, VarType(v) ' this way you retrieve to a variant, result is a string
end sub
Martin Kotulla
SoftMaker Software GmbH

SteveF48
Posts: 20
Joined: Thu Jul 11, 2013 11:32 am
Location: Deal, Kent, UK

Re: Cell contents

Post by SteveF48 » Wed Aug 03, 2016 3:29 pm

I'm not using variables, so I'll have to remember to cast the cell's value to the correct data, if not string.
Thanks
Thanks in advance,
Steve

Post Reply

Return to “BasicMaker 2016 for Windows”