Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Schongar P.VBScript unleashed.1997

.pdf
Скачиваний:
46
Добавлен:
23.08.2013
Размер:
1.59 Mб
Скачать

IEChart1.ChartType=CInt(left(ComboBox1.Text,2))

End Sub

Because the Text property of the ComboBox control begins with the setting for the ChartType property, the program isolates this value, converts it to an integer value, and assigns it to the ChartType property of the Chart control.

The complete listing of the Chart project is shown in Listing 9.5.

Listing 9.5. The Chart project.

1:<HTML>

2:<HEAD>

3:<SCRIPT LANGUAGE="VBScript">

4:<!--

5:Sub ComboBox1_Change()

6:IEChart1.ChartType=CInt(left(ComboBox1.Text,2))

7:end sub

8:

9:Sub ComboBox2_Change()

10:IEChart1.HGridStyle=CInt(left(ComboBox2.Text,2))

11:End Sub

12:

13:Sub ComboBox3_Change()

14:IEChart1.VGridStyle=CInt(left(ComboBox3.Text,1))

15:End Sub

16:

17:Sub ComboBox4_Change()

18:IEChart1.GridPlacement=CInt(left(ComboBox4.Text,1))

19:end sub

20:

21: Sub Layout1_OnLoad()

22:ComboBox1.AddItem "0 - Pie"

23:ComboBox1.AddItem "2 - Point"

24:ComboBox1.AddItem "5 - Line"

25:ComboBox1.AddItem "8 - Area"

26:ComboBox1.AddItem "11 - Column"

27:ComboBox1.AddItem "14 - Bar"

28:ComboBox1.Text= "8 - Area"

29:ComboBox2.AddItem "0 - No Grid"

30:ComboBox2.AddItem "1 - Solid Grid"

31:ComboBox2.AddItem "2 - Bold Grid"

32:ComboBox2.AddItem "3 - Dotted Grid"

33:ComboBox2.AddItem "4 - Bold Dotted Grid"

34:ComboBox2.Text= "0 - No Grid"

35:ComboBox3.AddItem "0 - No Grid"

36:ComboBox3.AddItem "1 - Solid Grid"

37:ComboBox3.AddItem "2 - Bold Grid"

38:ComboBox3.AddItem "3 - Dotted Grid"

39:ComboBox3.AddItem "4 - Bold Dotted Grid"

40:ComboBox3.Text= "0 - No Grid"

41:ComboBox4.AddItem "0 - Background Grid"

42:ComboBox4.AddItem "1 - Foreground Grid"

44:IEchart1.RowIndex = 0

45:IEchart1.RowName = "1996"

46:IEchart1.RowIndex = 1

47:IEchart1.RowName = "1997"

48:IEchart1.RowIndex = 2

49:IEchart1.RowName = "1998"

50:IEchart1.RowIndex = 3

51: IEchart1.RowName = "1999"

52:

53:IEchart1.ColumnIndex = 0

54:IEchart1.ColumnName = "Domestic"

55:IEchart1.ColumnIndex = 1

56:IEchart1.ColumnName = "Europe"

57:IEchart1.ColumnIndex = 2

58:IEchart1.ColumnName = "Japan"

60:end sub

61:-->

62:</SCRIPT>

63:</HEAD>

64:<BODY>

65:<CENTER>

66:<DIV ID="Layout1" STYLE="LAYOUT:FIXED;WIDTH:428pt; HEIGHT:300pt;">

67:<OBJECT ID="iechart1"

68:CLASSID="CLSID:FC25B780-75BE-11CF-8B01-444553540000"

STYLE="TOP:58pt;LEFT:25pt;WIDTH:256pt;HEIGHT:182pt;

ZINDEX:0;">

69: <PARAM NAME="_ExtentX" VALUE="9022">

70: <PARAM NAME="_ExtentY" VALUE="6429">

71: <PARAM NAME="Rows" VALUE="4">

72: <PARAM NAME="Columns" VALUE="3">

73: <PARAM NAME="ChartType" VALUE="8">

74: <PARAM NAME="Data[0][0]" VALUE="9">

75: <PARAM NAME="Data[0][1]" VALUE="10">

76: <PARAM NAME="Data[0][2]" VALUE="11">

77: <PARAM NAME="Data[1][0]" VALUE="7">

78: <PARAM NAME="Data[1][1]" VALUE="11">

79: <PARAM NAME="Data[1][2]" VALUE="12">

80: <PARAM NAME="Data[2][0]" VALUE="6">

81: <PARAM NAME="Data[2][1]" VALUE="12">

82: <PARAM NAME="Data[2][2]" VALUE="13">

83: <PARAM NAME="Data[3][0]" VALUE="16">

84: <PARAM NAME="Data[3][1]" VALUE="13">

85: <PARAM NAME="Data[3][2]" VALUE="14">

86: <PARAM NAME="HorizontalAxis" VALUE="0">

87: <PARAM NAME="VerticalAxis" VALUE="0">

88: <PARAM NAME="hgridStyle" VALUE="0">

89: <PARAM NAME="vgridStyle" VALUE="0">

90: <PARAM NAME="ColorScheme" VALUE="0">

91: <PARAM NAME="BackStyle" VALUE="1">

92: <PARAM NAME="Scale" VALUE="100">

93: <PARAM NAME="DisplayLegend" VALUE="0">

94: <PARAM NAME="BackColor" VALUE="16777215">

95: <PARAM NAME="ForeColor" VALUE="32768">

96:</OBJECT>

97:<OBJECT ID="ComboBox1"

98:CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002f3"

STYLE="TOP:83pt;LEFT:297pt;WIDTH:116pt;HEIGHT:17pt;

TABINDEX:0;

ZINDEX:1;">

99: <PARAM NAME="VariousPropertyBits" VALUE="746604571">

100: <PARAM NAME="DisplayStyle" VALUE="7">

101: <PARAM NAME="Size" VALUE="4092;600">

102: <PARAM NAME="MatchEntry" VALUE="1">

103: <PARAM NAME="ShowDropButtonWhen" VALUE="2">

104: <PARAM NAME="FontCharSet" VALUE="0">

105: <PARAM NAME="FontPitchAndFamily" VALUE="2">

106: <PARAM NAME="FontWeight" VALUE="0">

107:</OBJECT>

108:<OBJECT ID="ComboBox2"

109:CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002f3"

STYLE="TOP:124pt;LEFT:297pt;WIDTH:116pt;HEIGHT:17pt;

TABINDEX:1;

ZINDEX:2;">

110: <PARAM NAME="VariousPropertyBits" VALUE="746604571">

111: <PARAM NAME="DisplayStyle" VALUE="7">

112: <PARAM NAME="Size" VALUE="4092;600">

113: <PARAM NAME="MatchEntry" VALUE="1">

114: <PARAM NAME="ShowDropButtonWhen" VALUE="2">

115: <PARAM NAME="FontCharSet" VALUE="0">

116: <PARAM NAME="FontPitchAndFamily" VALUE="2">

117: <PARAM NAME="FontWeight" VALUE="0">

118:</OBJECT>

119:<OBJECT ID="ComboBox3"

120:CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002f3"

STYLE="TOP:165pt;LEFT:297pt;WIDTH:116pt;HEIGHT:17pt;

TABINDEX:3;

ZINDEX:3;">

121: <PARAM NAME="VariousPropertyBits" VALUE="746604571">

122: <PARAM NAME="DisplayStyle" VALUE="7">

123: <PARAM NAME="Size" VALUE="4092;600">

124: <PARAM NAME="MatchEntry" VALUE="1">

125: <PARAM NAME="ShowDropButtonWhen" VALUE="2">

126: <PARAM NAME="FontCharSet" VALUE="0">

127: <PARAM NAME="FontPitchAndFamily" VALUE="2">

128: <PARAM NAME="FontWeight" VALUE="0">

129:</OBJECT>

130:<OBJECT ID="ComboBox4"

131:CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002f3"

STYLE="TOP:206pt;LEFT:297pt;WIDTH:116pt;HEIGHT:17pt;

TABINDEX:2;

ZINDEX:4;">

132: <PARAM NAME="VariousPropertyBits" VALUE="746604571">

133: <PARAM NAME="DisplayStyle" VALUE="7">

134: <PARAM NAME="Size" VALUE="4092;600">

135: <PARAM NAME="MatchEntry" VALUE="1">

136: <PARAM NAME="ShowDropButtonWhen" VALUE="2">

137: <PARAM NAME="FontCharSet" VALUE="0">

138: <PARAM NAME="FontPitchAndFamily" VALUE="2">

139: <PARAM NAME="FontWeight" VALUE="0">

140:</OBJECT>

141:<OBJECT ID="Label1"

142:CLASSID="CLSID:978C9E23-D4B0-11CE-Bf2D-00AA003f40D0"

STYLE="TOP:66pt;LEFT:297pt;WIDTH:99pt;HEIGHT:17pt;

ZINDEX:5;">

143: <PARAM NAME="Caption" VALUE="Chart Type">

144: <PARAM NAME="Size" VALUE="3493;600">

145: <PARAM NAME="FontName" VALUE="Verdana">

146: <PARAM NAME="FontHeight" VALUE="200">

147: <PARAM NAME="FontCharSet" VALUE="0">

148: <PARAM NAME="FontPitchAndFamily" VALUE="2">

149: <PARAM NAME="FontWeight" VALUE="0">

150:</OBJECT>

151:<OBJECT ID="Label2"

152:CLASSID="CLSID:978C9E23-D4B0-11CE-Bf2D-00AA003f40D0"

STYLE="TOP:107pt;LEFT:297pt;WIDTH:116pt;HEIGHT:17pt;

ZINDEX:6;">

153: <PARAM NAME="Caption" VALUE="Horizontal Grid Style">

154: <PARAM NAME="Size" VALUE="4092;600">

155: <PARAM NAME="FontName" VALUE="Verdana">

156: <PARAM NAME="FontHeight" VALUE="200">

157: <PARAM NAME="FontCharSet" VALUE="0">

158: <PARAM NAME="FontPitchAndFamily" VALUE="2">

159: <PARAM NAME="FontWeight" VALUE="0">

160:</OBJECT>

161:<OBJECT ID="Label3"

162:CLASSID="CLSID:978C9E23-D4B0-11CE-Bf2D-00AA003f40D0"

STYLE="TOP:149pt;LEFT:297pt;WIDTH:99pt;HEIGHT:17pt;

ZINDEX:7;">

163: <PARAM NAME="Caption" VALUE="Vertical Grid Style">

164: <PARAM NAME="Size" VALUE="3493;600">

165: <PARAM NAME="FontName" VALUE="Verdana">

166: <PARAM NAME="FontHeight" VALUE="200">

167: <PARAM NAME="FontCharSet" VALUE="0">

168: <PARAM NAME="FontPitchAndFamily" VALUE="2">

169: <PARAM NAME="FontWeight" VALUE="0">

170:</OBJECT>

171:<OBJECT ID="Label4"

172:CLASSID="CLSID:978C9E23-D4B0-11CE-Bf2D-00AA003f40D0"

STYLE="TOP:190pt;LEFT:297pt;WIDTH:99pt;HEIGHT:17pt;

ZINDEX:8;">

173: <PARAM NAME="Caption" VALUE="Grid Placement">

174: <PARAM NAME="Size" VALUE="3493;600">

175: <PARAM NAME="FontName" VALUE="Verdana">

176: <PARAM NAME="FontHeight" VALUE="200">

177: <PARAM NAME="FontCharSet" VALUE="0">

178: <PARAM NAME="FontPitchAndFamily" VALUE="2">

179: <PARAM NAME="FontWeight" VALUE="0">

180:</OBJECT>

181:<OBJECT ID="Label5"

182:CLASSID="CLSID:978C9E23-D4B0-11CE-Bf2D-00AA003f40D0"

STYLE="TOP:8pt;LEFT:17pt;WIDTH:404pt;HEIGHT:33pt;

ZINDEX:9;">

183: <PARAM NAME="Caption" VALUE="Chart Sampler">

184: <PARAM NAME="Size" VALUE="14252;1164">

185: <PARAM NAME="SpecialEffect" VALUE="1">

186: <PARAM NAME="FontName" VALUE="Verdana">

187: <PARAM NAME="FontHeight" VALUE="400">

188: <PARAM NAME="FontCharSet" VALUE="0">

189: <PARAM NAME="FontPitchAndFamily" VALUE="2">

190: <PARAM NAME="ParagraphAlign" VALUE="3">

191: <PARAM NAME="FontWeight" VALUE="0">

192:</OBJECT>

193:<OBJECT ID="Image1"

194:CLASSID="CLSID:D4A97620-8E8F-11CF-93CD-00AA00C08FDF"

STYLE="TOP:50pt;LEFT:17pt;WIDTH:404pt;HEIGHT:206pt;

ZINDEX:10;">

195: <PARAM NAME="BorderStyle" VALUE="0">

196: <PARAM NAME="SizeMode" VALUE="3">

197: <PARAM NAME="SpecialEffect" VALUE="1">

198: <PARAM NAME="Size" VALUE="14252;7267">

199: <PARAM NAME="PictureAlignment" VALUE="0">

200: <PARAM NAME="VariousPropertyBits" VALUE="19">

201:</OBJECT>

202:</DIV>

203:</BODY>

204:</HTML>

Figure 9.10 shows the ChartURL document, which is a variation on the Chart document. This time we've added a command button that causes the Chart control to read its data and settings from a local file. The file with the data and settings is called CHARTDATA.TXT, and it contains the sample data of the section titled "Supplying Data Over the Internet." When the user clicks this command button, the Chart control reads the data from the CHARTDATA file and updates the graph accordingly. The code behind the Load from File button simply assigns a value to the Chart control's URL property:

Figure 9.10 : The ChartURL document can read its data and settings from a local file or a URL.

Sub ComboBox1_Change()

IEChart1.ChartType=CInt(left(ComboBox1.Text,2))

End Sub

On the CD you will find the CHARTDATA.TXT file, and you can experiment with it. If you can automate the generation of similar files, you can post graphs with live data on the Web. For example, you can write an application that retrieves numeric data from a database and prepares a file with the information needed by the Chart control to graph the data, including the headings. And as you probably know, it takes much less space to store a few dozen numbers than it takes to store the image of the graph that corresponds to these data.

Review

The Chart control is the last of the new ActiveX controls we are going to cover in this book. If you are using some visual programming tools in the Windows environment, you have realized that the ActiveX controls are nothing more than the regular OLE controls that make up the Windows user interface. You are probably wondering whether you should attempt to use the OLE controls already installed on your system. Most of the OLE controls can be used, and we'll look at a few of them in the last part of the book. However, they are not ActiveX controls and the viewers will get a warning every time they open a page that contains old OLE controls (implemented in OCX files). You can use the existing OLE controls on your pages in an intranet environment, and you are going to find interesting examples in the last section of this book.

The ActiveX controls released by Microsoft after the release of Internet Explorer 3.0 and the ActiveX Control Pad are posted at Microsoft's ActiveX Component Gallery at www. microsoft.com/activex/controls. The ActiveX Gallery is the site to visit when you need an ActiveX control for your projects. You will find there a list of all available ActiveX controls from Microsoft and other companies, descriptions of the controls, and the actual controls. Microsoft's ActiveX controls are free, but most of the other ActiveX controls aren't-and you should read the documentation and distribution notes before you download and use them.