-
<%@ Page language="VB" %>
<script runat="server">
dim arrColors(5) as String
sub Page_Load(obj as object, e as eventargs)
arrColor(0) = "green"
arrColor(1) = "red"
arrColor(2) = "yellow"
arrColor(3) = "blue"
arrColor(4) = "violet"
Response.Write("The first element is: ")
Response.Write(arrColor(0)&"<p>")
Response.Write("The third element is: ")
Response.Write(arrColor(2) & "<p>")
end sub
</script>
<html>
<body>
</body>
</html>
ReDim Preserver arrColor(12) 增加长度
Erase arrColor 清空数组
if (condition ) then
some code
end if
Select Case variable
Case option1
code
Case Else
code
End
Select Case FirstName
Case "sun"
Response.Write("")
Case "Paul"
Response.Write("ds")
End Select
while condition
code
End While
dim intCount as Integer = 1
while intCount < 10
Response.Write(intCount & "<pr>")
intCount = intCount -1;
End While
For intCount = 1 to 12
Response.Write(intCount)
Next
在VB.NET中有两种分支逻辑:函数和子程序,去区别在于函数能返回信息,而子程序不能。
Sub name(parameters)
code
End Sub
function name(parameters) as type
code
Return value
end function
sub Page_Load(obj as object, e as eventargs)
code
end sub
<script runat="server">
sub Page_Load(obj as object, e as eventargs)
MultiplyNumbers(3,4)
MultiplyNumbers(3,6)
end sub
sub MultiplyNumbers(intA as integer, intB as integer)
Response.Wirte(intA*intB &<br>)
end sub
</script>
可选参数 function MutliplyNumbers(intA as integer, optional intB as integer) as Integer
<script runat="server">
Class Clock
public second as integer
public minute as integer
public hour as integer
sub SetTime(intSec as integer, intMin as integer,intHour as as integer)
Second = integer
Minute = intMin
hour = intHour
end sub
End Class
</script> -
2009-01-06
获取word页面的高度和宽度 - [VB]
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Doc As Microsoft.Office.Interop.Word.Document
Dim Docs As Microsoft.Office.Interop.Word.DocumentsDoc = GetObject("D:\19.doc")
Dim i, j As Single
i = Doc.PageSetup.PageHeight()
j = Doc.PageSetup.PageWidthDim Msg1 As String
Msg1 = i
Dim Msg2 As StringMsg2= j
MessageBox.Show("Height:" + Msg1 + " " + "Width:" + Msg2, "My Application", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Doc.Activate()End Sub
End Class
1CM=28.346像素







