資訊系統與實習 製作 : 林郁君 一 2009.09.28 9X9 'button 被按下後 ' Dim i, j As Integer For i = 1 To 9 'i 從 1 到 9' For j = 1 To 9 'j 從 1 到 9' If j * i < 10 Then ' 如果 j 乘上 i 是為個位數 ' Response.Write(i & "*" & j & " =" & i * j & " " & " " & " ") ' 顯示則為 i*j=( 中間有空格 ) 相乘後的數 ' Else ' 若 j 乘上 i 是為十位數 ' Response.Write(i & "*" & j & "=" & i * j & " " & " ") ' 顯示則為 'i*j= 相乘後的數 ' Next j Response.Write("<br/>") ' 換行 ' Next i 二
2009.10.05 星星排列 _for loop Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim h As Integer = 7 'h 為變數 ' Dim i, j As Integer For i = 1 To h Step 2 'i 從第 1 層到第 7 層每次增加 2 顆星星 ' For j = 1 To i ' 每層帶入 ' Response.Write("*") ' 顯示出 *' Next j Response.Write("<br/>") ' 每次跳行 ' Next i For i = h 2 To 1 Step 2 ' 從第 7 層開始每往下一層就減 2 顆星星 ' For j = 1 To i ' 每層帶入 ' Response.Write("*") ' 顯示出 *' Next j Response.Write("<br/>") ' 每次跳行 ' Next i 三 2009.10.05 陣列運算 Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim a(5) As Integer 'a(5) 為陣列, 從 a(0) 開始到 a(5) 共為 6 個數 ' Dim i, sum As Integer a(0) = 1 'a(0) 為 1' a(1) = 2 'a(1) 為 2' a(2) = 3 'a(2) 為 3' For i = 0 To 2 ' 從 a(0) 到 a(2)' sum += a(i) 'sum 這個總和為 a(i) 們累加 ' Next i Response.Write(sum) ' 顯示 sum 總和 ' 會直接出現數字 6
四 2009.10.19_for each 老師示範檔 Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim num As Integer = 0, sum As Integer = 0 Dim M, A(30) As Integer Response.Write("1 到 30 間不能被 9 整除的數有 ") For num = 1 To 30 If num Mod 9 = 0 Then A(num) = 0 A(num) = num Next num For M = 1 To 30 If A(M) <> 0 Then Response.Write(A(M) & " ") sum += M Next Response.Write("<p> 以上數字的總和為 " & sum & "</p>") 五 2009.10.19_for each Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim num As Integer = 0, sum As Integer = 0 Dim M, A(30) As Integer
Response.Write("1 到 30 間不能被 9 整除的數有 ") For num = 1 To 30 If num Mod 9 = 0 Then A(num) = 0 A(num) = num Next num For M = A(1) To A(30) If M Mod 9 = 0 Then If M <> 0 Then sum += M Response.Write(M & " ") Next Response.Write("<p> 以上數字的總和為 " & sum & "</p>") 六 2009.10.19_for loop 1~n 總和 Dim num As Integer = 0, sum As Integer = 0, N As Integer = TextBox1.Text For num = 1 To N sum += num Next Response.Write("<p> 以上數字的總和為 " & sum & "</p>") 七
2009.10.19_for loop Protected Sub Page_Load(ByVal sender As Object, ByVal e As Dim num As Integer = 0, sum As Integer = 0 Dim M, A(30) As Integer Response.Write("1 到 30 間不能被 9 整除的數有 ") For num = 1 To 30 If num Mod 9 = 0 Then A(num) = 0 A(num) = num Next num For M = A(1) To A(30) If M Mod 9 = 0 Then If M <> 0 Then sum += M Response.Write(M & " ") Next Response.Write("<p> 以上數字的總和為 " & sum & "</p>") 八 2009.10.19_ 密碼輸入相同 If TextBox1.Text = TextBox2.Text Then Response.Write(" 兩次密碼相同 ") Else Response.Write(" 兩次密碼不同 ")
九 2009.10.26_ 留言版 Dim userinput As String ' 輸入的數字為字串 ' userinput = TextBox1.Text.Replace(" ", " ") ' 用 userinput 取代 textbox 括號內意思是空白是被取代的 userinput = userinput.replace(vbcrlf, "<br/>") 'useinput 取代 ( 用逗號隔 ) vbcrlf 為 VB 的語言然後用逗號 Replace 以 html 的語言 <br/> 帶入 ' userinput = "[" & Now.ToString & "]<br />" & userinput 'userinput 把數值轉換成字串時間 + 換行 + 所打內容 ' Label1.Text = "<hr />" & userinput & Label1.Text 'label1 會顯示分隔線 + 所打內容 (old)+ 所打內容 (NEW)'
TextBox1.Text = " " 'Textbox 清除 ' 十 點選 button 後出現圖片再點選圖片後連結到圖片網站 2009.11.02_post.image ImageButton1.Visible = True ImageButton1.ImageUrl = "~/image/google2.jpg" Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) ImageButton1.PostBackUrl = "http://www.google.com.tw" Protected Sub Button2_Click(ByVal sender As Object, ByVal e As ImageButton2.Visible = True ImageButton2.ImageUrl = "~/image/pchome.jpg" Protected Sub ImageButton2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) ImageButton2.PostBackUrl = "http://www.pchome.com.tw" Protected Sub Button3_Click(ByVal sender As Object, ByVal e As ImageButton3.Visible = True ImageButton2.ImageUrl = "~/image/yahoo.jpg" Protected Sub ImageButton3_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) ImageButton3.PostBackUrl = "http://www.yahoo.com.tw" 2009.11.02_ 字型字體. Label1.ForeColor = Drawing.Color.Red Protected Sub Button2_Click(ByVal sender As Object, ByVal e As Label1.ForeColor = Drawing.Color.Blue Protected Sub Button3_Click(ByVal sender As Object, ByVal e As Label1.ForeColor = Drawing.Color.Green Protected Sub Button4_Click(ByVal sender As Object, ByVal e As Label1.Font.Name = "Arial" Protected Sub Button5_Click(ByVal sender As Object, ByVal e As Label1.Font.Name = "Times New Roman"
Protected Sub Button6_Click(ByVal sender As Object, ByVal e As Label1.Font.Name = "Bell MT" Protected Sub Button7_Click(ByVal sender As Object, ByVal e As Label1.Font.Italic = True Protected Sub Button8_Click(ByVal sender As Object, ByVal e As Label1.Font.Italic = False Label1.Font.Bold = False Protected Sub Button9_Click(ByVal sender As Object, ByVal e As Label1.Font.Bold = True Protected Sub Button10_Click(ByVal sender As Object, ByVal e As Label1.Font.Size = FontSize.Medium Protected Sub Button11_Click(ByVal sender As Object, ByVal e As Label1.Font.Size = FontSize.Large Protected Sub Button12_Click(ByVal sender As Object, ByVal e As Label1.Font.Size = FontSize.Small