By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,619 Members | 1,534 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,619 IT Pros & Developers. It's quick & easy.

Msg Box not displaying messages

P: n/a
I have the folowing code..the logic according to me is correct..but I
dont know...the msg boxes are not displaying anything...am I supposed
to change any settings ???


Public Class Form1
Inherits System.Windows.Forms.Form
'declare the number variable
Dim num As Integer
#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans
Serif", 14.0!, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(256, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Guessing Game"
Me.Label1.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 64)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(256, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(80, 112)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 24)
Me.Button1.TabIndex = 2
Me.Button1.Text = "GUESS"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'make sure the TextBox contains a number
If IsNumeric(TextBox1.Text) = False Then
MsgBox("Please enter a number between 1 and 10!")
Exit Sub
End If

'make sure the number is between 1 and 10
If Val(TextBox1.Text) < 1 Or Val(TextBox1.Text) > 10 Then
MsgBox("Please enter a number between 1 and 10!")
Exit Sub
End If

'check for high answer
If Val(TextBox1.Text) > num Then
MsgBox("That number is too high")
ElseIf Val(TextBox1.Text) < num Then
MsgBox("That number is too low")
Else
MsgBox("That number is CORRECT!")
End
End If

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Randomize()
num = Int((Rnd() * 6) + 1)
End Sub
End Class

Feb 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
moumita,

If you mean that the message boxes are appearing but do not contain any
text, then are you running McAfee Enterprise virus software?

If so, then there is a patch for this problem at McAfee's web site.

Kerry Moorman
"moumita" wrote:
I have the folowing code..the logic according to me is correct..but I
dont know...the msg boxes are not displaying anything...am I supposed
to change any settings ???


Public Class Form1
Inherits System.Windows.Forms.Form
'declare the number variable
Dim num As Integer
#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans
Serif", 14.0!, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(256, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Guessing Game"
Me.Label1.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 64)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(256, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(80, 112)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 24)
Me.Button1.TabIndex = 2
Me.Button1.Text = "GUESS"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'make sure the TextBox contains a number
If IsNumeric(TextBox1.Text) = False Then
MsgBox("Please enter a number between 1 and 10!")
Exit Sub
End If

'make sure the number is between 1 and 10
If Val(TextBox1.Text) < 1 Or Val(TextBox1.Text) > 10 Then
MsgBox("Please enter a number between 1 and 10!")
Exit Sub
End If

'check for high answer
If Val(TextBox1.Text) > num Then
MsgBox("That number is too high")
ElseIf Val(TextBox1.Text) < num Then
MsgBox("That number is too low")
Else
MsgBox("That number is CORRECT!")
End
End If

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Randomize()
num = Int((Rnd() * 6) + 1)
End Sub
End Class

Feb 10 '06 #2

P: n/a
"moumita" <mo*******@gmail.com> schrieb:
I have the folowing code..the logic according to me is correct..but I
dont know...the msg boxes are not displaying anything...am I supposed
to change any settings ???


Fixing the problem of missing text in controls and messageboxes
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=controlsmissingtextbug&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Feb 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.