Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass a array as a parameter from input box into VB script

Status
Not open for further replies.

jimmyweb

Programmer
Dec 9, 2004
37
US
Hi,
I created a chart script and works. Could we let you input a series of value to support X and Y?
Users can enter a series of value for X value at one input box and other input box for Y value.
Any idea?
xx value should be as "6/6/2005","6/7/2005","6/8/2005","6/9/2005","6/10/2005","6/11/2005","6/12/2005","6/13/2005","6/14/2005"
yy valus as 0.3,0.07, 0.1,0.4,0.08,0.2,0.2,0.5,2.5
Thanks for any help.
jim

See my source code.
____________________________

<%@ Language=VBScript %>
<HTML>
<head><title>calls chart example</title></head>
<STRONG><CENTER>Calls Per Day </CENTER></STRONG>

<BODY>
<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 style="width:100%;height:480"></object>
<object id=Spreadsheet1 classid=CLSID:0002E510-0000-0000-C000-000000000046 style="width:100%;height:480"></object>

<script language=vbs>
Sub Window_OnLoad(xx, yy)

class
Dim oSheet
Set oSheet = Spreadsheet1.ActiveSheet
oSheet.Cells.Clear
oSheet.Range("A2:A10").Value = Array(xx)
oSheet.Range("B1:B10").Value = Array("OBC", yy)

Dim oChart
ChartSpace1.Clear
Set oChart = ChartSpace1.Charts.Add

' Set the Spreadsheet component as the data source for the chart
ChartSpace1.DataSource = Spreadsheet1

dim c
set c = ChartSpace1.Constants

'Add the data to the chart and set the series names
dim oSeries

for i=1 to 1
Set oSeries = oChart.SeriesCollection.Add
oSeries.SetData c.chDimValues, 0, oSheet.Range(oSheet.Cells(2,1), oSheet.Cells(10,1)).Address
oSeries.SetData c.chDimSeriesNames, 0, oSheet.Cells(1,1).Address
next

oChart.SetData c.chDimCategories, 0, "a2:a10"

oChart.Axes(c.chAxisPositionLeft).NumberFormat = "0"
oChart.Axes(c.chAxisPositionLeft).MajorUnit = 0.5

End Sub
</script>


</BODY>
</HTML>

****



 
strX = InputBox("please enter X co-ords, delimited with ",")
aArray = Split(strX, ",")
 
Hi Mrmovie and Friends,
Thanks for your help.
Based on your code. i used XArry and YArry to hold series of value. However,it does not display in syntax(oSheet.Range("A2:A59").Value =XArray)
this codes should be as ("A2:A59").Value =Array(04-JUN-05,06-JUN-05,07-JUN-05,...);

How to fix this problem?
Jim

*** original code from borrow
<%@ language=VBScript%><HTML>
<head><title>Presuit chart example</title></head>
<input type="hidden" value="JavaScript" name="VBScript">
<STRONG><CENTER>Presuit Outbound & Inbound Calls Per Day OBC</CENTER></STRONG>
<BODY>
<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 style="width:100%;height:480"></object>
<object id=Spreadsheet1 classid=CLSID:0002E510-0000-0000-C000-000000000046 style="width:100%;height:480"></object>
<script language=vbs>
Sub Window_OnLoad(x,y)
XArray = Split(04-JUN-05,06-JUN-05,07-JUN-05,08-JUN-05,09-JUN-05,10-JUN-05,11-JUN-05,13-JUN-05,14-JUN-05,15-JUN-05,16-JUN-05,17-JUN-05,18-JUN-05,20-JUN-05,21-JUN-05,22-JUN-05,23-JUN-05,24-JUN-05,25-JUN-05,27-JUN-05,28-JUN-05,29-JUN-05,30-JUN-05,01-JUL-05,02-JUL-05,05-JUL-05,06-JUL-05,07-JUL-05,08-JUL-05,09-JUL-05,11-JUL-05,12-JUL-05,13-JUL-05,14-JUL-05,15-JUL-05,16-JUL-05,18-JUL-05,19-JUL-05,20-JUL-05,21-JUL-05,22-JUL-05,23-JUL-05,25-JUL-05,26-JUL-05,27-JUL-05,28-JUL-05,29-JUL-05,30-JUL-05,01-AUG-05,31-JUL-05,24-JUL-05,17-JUL-05,10-JUL-05,04-JUL-05,03-JUL-05,05-JUN-05,12-JUN-05,19-JUN-05,26-JUN-05,",");
YArray = Split("OBC",30990,239671,360313,347051,319227,227757,272552,327918,283048,290757,369310,368734,270274,460904,431012,425798,438662,411728,324900,533868,579755,470311,500128,391676,218867,488972,484139,534830,473239,251196,493598,483152,498561,521669,400963,304903,509109,596611,628224,625632,272331,452178,586995,635640,650573,620445,577680,284185,599555,219367,554359,299681,370445,441889,364320,213239,121935,334268,403969,",");
Dim oSheet
Set oSheet = Spreadsheet1.ActiveSheet
oSheet.Cells.Clear
oSheet.Range("A2:A59").Value =XArray
oSheet.Range("B1:B59").Value = YArray
Dim oChart
ChartSpace1.Clear
Set oChart = ChartSpace1.Charts.Add
ChartSpace1.DataSource = Spreadsheet1
dim c
set c = ChartSpace1.Constants
dim oSeries
for i=1 to 1
Set oSeries = oChart.SeriesCollection.Add
oSeries.SetData c.chDimSeriesNames, 0, oSheet.Cells(1,1).Address
oSeries.SetData c.chDimValues, 0, oSheet.Range(oSheet.Cells(2,2), oSheet.Cells(59,2)).Address
next
oChart.SetData c.chDimCategories, 0, "a2:a59"
ChartSpace1.Charts(0).HasLegend = false
oChart.Axes(c.chAxisPositionLeft).NumberFormat = "0.0"
oChart.Axes(c.chAxisPositionLeft).MajorUnit = 25
End Sub
</script>
</BODY>
</HTML>
 
myArray = Array(value1, value2, ..., valueN)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV (MIS) and friends,
problem is that how can i get a whole value of array in syntax(oSheet.Range("A2:A10").Value= array( array value).
such as
("A2:A59").Value =Array("04-JUN-05","06-JUN-05","07-JUN-05");


I am a new person in VB script .

Thanks
Jim
 
Hi friends,
I declare a and b as array and put 2 string value into array.
but it still as oSheet.Range("A2:A59").Value = a ;
it should be as oSheet.Range("A2:A59").Value = array("04-JUN-05","06-JUN-05",....);
what is wrong?
Thanks for any help!!!
JIm
********source code
Sub Window_OnLoad(x,y)
dim XArray = Split("04-JUN-05","06-JUN-05","07-JUN-05","08-JUN-05","09-JUN-05","10-JUN-05","11-JUN-05","13-JUN-05","14-JUN-05","15-JUN-05","16-JUN-05","17-JUN-05","18-JUN-05","20-JUN-05","21-JUN-05","22-JUN-05","23-JUN-05","24-JUN-05","25-JUN-05","27-JUN-05","28-JUN-05","29-JUN-05","30-JUN-05","01-JUL-05","02-JUL-05","05-JUL-05","06-JUL-05","07-JUL-05","08-JUL-05","09-JUL-05","11-JUL-05","12-JUL-05","13-JUL-05","14-JUL-05","15-JUL-05","16-JUL-05","18-JUL-05","19-JUL-05","20-JUL-05","21-JUL-05","22-JUL-05","23-JUL-05","25-JUL-05","26-JUL-05","27-JUL-05","28-JUL-05","29-JUL-05","30-JUL-05","01-AUG-05","31-JUL-05","24-JUL-05","17-JUL-05","10-JUL-05","04-JUL-05","03-JUL-05","05-JUN-05","12-JUN-05","19-JUN-05","26-JUN-05",",");
dim YArray = Split("OBC","30990","239671","360313","347051","319227","227757","272552","327918","283048","290757","369310","368734","270274","460904","431012","425798","438662","411728","324900","533868","579755","470311","500128","391676","218867","488972","484139","534830","473239","251196","493598","483152","498561","521669","400963","304903","509109","596611","628224","625632","272331","452178","586995","635640","650573","620445","577680","284185","599555","219367","554359","299681","370445","441889","364320","213239","121935","334268","403969",",");
dim a
a=Array("04-JUN-05","06-JUN-05","07-JUN-05","08-JUN-05","09-JUN-05","10-JUN-05","11-JUN-05","13-JUN-05","14-JUN-05","15-JUN-05","16-JUN-05","17-JUN-05","18-JUN-05","20-JUN-05","21-JUN-05","22-JUN-05","23-JUN-05","24-JUN-05","25-JUN-05","27-JUN-05","28-JUN-05","29-JUN-05","30-JUN-05","01-JUL-05","02-JUL-05","05-JUL-05","06-JUL-05","07-JUL-05","08-JUL-05","09-JUL-05","11-JUL-05","12-JUL-05","13-JUL-05","14-JUL-05","15-JUL-05","16-JUL-05","18-JUL-05","19-JUL-05","20-JUL-05","21-JUL-05","22-JUL-05","23-JUL-05","25-JUL-05","26-JUL-05","27-JUL-05","28-JUL-05","29-JUL-05","30-JUL-05","01-AUG-05","31-JUL-05","24-JUL-05","17-JUL-05","10-JUL-05","04-JUL-05","03-JUL-05","05-JUN-05","12-JUN-05","19-JUN-05","26-JUN-05")
dim b
b=Array("30990","239671","360313","347051","319227","227757","272552","327918","283048","290757","369310","368734","270274","460904","431012","425798","438662","411728","324900","533868","579755","470311","500128","391676","218867","488972","484139","534830","473239","251196","493598","483152","498561","521669","400963","304903","509109","596611","628224","625632","272331","452178","586995","635640","650573","620445","577680","284185","599555","219367","554359","299681","370445","441889","364320","213239","121935","334268","403969")
Dim oSheet
Set oSheet = Spreadsheet1.ActiveSheet
oSheet.Cells.Clear
oSheet.Range("A2:A59").Value = a ;
oSheet.Range("B1:B59").Value = b;
 
[1] Why do you use semi-colon to end a line in vbs? You can't do that.
[2] This kind of lines is incorrect for multiple reason.
>[tt]dim XArray = Split("04-JUN-05","06-JUN-05",...,"26-JUN-05",",");[/tt]
[tt]dim XArray
XArray=array("04-JUN-05","06-JUN-05",...,"26-JUN-05")[/tt]
[3] This fails because the underlining mechanics is 2-dim.
>[tt]oSheet.Range("A2:A59").Value = a ;[/tt]
Apart from the ending semi-colon, you've to transpose it.
[tt]oSheet.Range("A2:A59").Value = oxl.transpose(a)[/tt]
where oxl is the application object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top