Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

cqf1216 2005-06-08 12:48:58
如何去掉Handles MyBase.Load,我在VS里把它去掉后它还是会自动生成啊,因为我在页面的Protected Overrides Sub OnInit(ByVal e As EventArgs)有一段代码的,VS自动生成的Handles MyBase.Load让我的代码不能执行了
...全文
104 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
老戴12345654 2005-06-08
  • 打赏
  • 举报
回复
用 vs.net 是去不掉的吧,,,应该类似于 C#中的注册this.Load += new System.EventHandler(this.Page_Load);吧

如果你要拷到 code-inside 的aspx页面中,在把后面删除就好了

突然发现 VB.NET的IDE更加智能哦,C#里要不小心删除了就不会自动添加,有时候检查半天都检查不出来
Public Class Form1 Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged TextBox1.Font = New Font("宋体", TextBox1.Font.Size, TextBox1.Font.Style) End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged TextBox1.Font = New Font("隶书", TextBox1.Font.Size, TextBox1.Font.Style) End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged TextBox1.Font = New Font("黑体", TextBox1.Font.Size, TextBox1.Font.Style) End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) TextBox1.Font = New Font(TextBox1.Font.FontFamily, 12, TextBox1.Font.Style) End Sub Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) TextBox1.Font = New Font(TextBox1.Font.FontFamily, 18, TextBox1.Font.Style) End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) TextBox1.Font = New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size, TextBox1.Font.Style) End Sub Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) TextBox1.Font = New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size, TextBox1.Font.Style) End Sub Private Sub CheckBox1_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If (CheckBox1.Checked) Then TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Or FontStyle.Bold) Else TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Xor FontStyle.Bold) End If End Sub Private Sub Form1_Load(ByVal sender As System.Obje
Private Sub AxWindowsMediaPlayer1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Public Class Form1 Private Sub 文件ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub MenuItem15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCopy.Click rtBook.Copy() End Sub Private Sub MenuItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditPaste.Click rtBook.Paste() '粘贴操作 End Sub Private Sub rtBook_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtBook.TextChanged fsave = False '控件中的内容发生变化时,该标志为False End Sub Dim fsave As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '为全局变量赋值 '对保存文件对话框赋初值 SaveFileDialog1.FileName = "" SaveFileDialog1.DefaultExt = "txt" SaveFileDialog1.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*" SaveFileDialog1.Title = "保存" '对打开文件对话框赋初值 OpenFileDialog1.FileName = "" OpenFileDialog1.DefaultExt = "txt" OpenFileDialog1.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*" OpenFileDialog1.Title = "打开" End Sub Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click Dim num1 As Integer '如果文本已被保存,则清空rtBook内容,重置变量新建文本 If fsave Then rtBook.Clear() SaveFileDialog1.FileName = "" '文件如果还没有保存,则询问用户如何处理 Else num1 = MsgBox("文件的内容已被改变。想保存文件吗?", vbYesNoCancel + 48, "记事本") Select Case num1 '用户选择保存,而且该文件从未保存过,则执行保存文件的操作 Case 6 If SaveFileDialog1.FileName = "" Then If SaveFileDialog1.ShowDialog Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If '如果该文件已存在,则弹出对话框,要求用户回答后再保存 End If '清空RTbook的内容,重置变量新建文本 fsave = True rtBook.Clear() SaveFileDialog1.FileName = "" Case 7 '如果用户选择不保存,则立即清空RTbook的内容,新建文本 rtBook.Clear() SaveFileDialog1.FileName = "" fsave = True Case Else '用户选择取消操作,则什么也不做,取消这次的新建操作 End Select End If End Sub Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileOpen.Click Dim num1 As Integer '如果文件内容还未保存,则弹出对话框,询问用户如何处理 If Not fsave Then num1 = MsgBox("文件的内容已被改变。想要保存文件吗?", vbYesNoCancel + 48, "记事本") Select Case num1 Case 6 '用户选择保存操作,而且该文件从未保存过,则输入文件名后进行保存 If SaveFileDialog1.FileName = "" Then If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Else '若该文件已存在,则弹出对话框,用户选择保存后,直接保存 rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If '弹出【打开】对话框,执行打开文件的操作 fsave = True If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Case 7 '用户选择不保存文件,则直接打开文本文件 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) fsave = True End If Case Else '用户选择了取消操作 End Select Else '文本已被保存,直接打开文件进行操作 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If fsave = True End If End Sub Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click If SaveFileDialog1.FileName = "" Then '如果文件从未保存过,则弹出对话框,输入文件名后,直接保存 If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Else '若该文件以保存过,则弹出对话框后,用户选择保存后,直接保存到原文件中 rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If fsave = True End Sub Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSaveAs.Click '现将保存对话框的标题改为“另存为” SaveFileDialog1.Title = "另存为" If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) fsave = True End If '文件保存完成后,对话框标题再改为“另存” SaveFileDialog1.Title = "保存" End Sub Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click Close() End Sub Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditUndo.Click rtBook.Undo() '用户撤消操作 End Sub Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCut.Click rtBook.Cut() '剪切操作 End Sub Private Sub MenuItem19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditSelectAll.Click rtBook.SelectAll() '全选操作 End Sub Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditDelete.Click rtBook.Cut() End Sub Private Sub MenuItem20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFont.Click If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.Font = FontDialog1.Font '用户选择字体 End If End Sub Private Sub MenuItem21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBackcolor.Click If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.ForeColor = ColorDialog1.Color '选择文本的颜色 End If End Sub Private Sub MenuItem22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuForeColor.Click If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.BackColor = ColorDialog1.Color '选择文本框的背景颜色 End If End Sub Private Sub MenuItem23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click Dim 关于记事本 As Integer 关于记事本 = MsgBox("我的记事本 版本:1.0 版权所有(李振,吕红飞) 2004 http://www.hbsi.com.cn") End Sub
用VB.NET做的小游戏--打地鼠 Public Class Form1 Inherits System.Windows.Forms.Form Dim pic As New PictureBox Dim goal As Integer Dim i As Integer Dim j As Integer Dim xx1() As Integer = {135, 277, 417} Dim xx2() As Integer = {157, 367} Dim xx3() As Integer = {32, 251, 482} Dim timer As Double = 1 Dim count As Integer '计时器跳动次数 Dim ifclick As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Text = "小游戏" Me.Size = New Size(650, 465) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Interval = 600 Timer1.Enabled = True Button2.Visible = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Button2.Text = "暂停" Then Button2.Text = "继续" Timer1.Enabled = False PictureBox1.Enabled = False ElseIf Button2.Text = "继续" Then Button2.Text = "暂停" Timer1.Enabled = True PictureBox1.Enabled = True End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ifclick = False PictureBox1.Enabled = True If timer = 0 Then Timer1.Enabled = False MsgBox("游戏结束,您的得分:" + goal.ToString) Button3.Visible = False Exit Sub End If addpic() timer = 10 - count * 0.5

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧