Kirjautuminen

Haku

Tehtävät

Keskustelu: Ohjelmointikysymykset: VB.NET: VB.net MsgBox

Juice [06.08.2004 22:46:55]

#

Täh? Aiemmin käytin VB 3:sta ja sitten siirryin VB.netiin. Sitten kokeilen legendaarista esimerkkia, elikkä labeli, tekstikenttä ja buttoni ja sitten MsgBox terve, Juice. Noh, errori tulee. Name 'MsgBox' is not declared

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace DefaultNamespace

	Public Class MainForm
		Inherits System.Windows.Forms.Form
		Private label1 As System.Windows.Forms.Label
		Private button1 As System.Windows.Forms.Button
		Private textBox1 As System.Windows.Forms.TextBox


		Public Shared Sub Main
			Dim fMainForm As New MainForm
			fMainForm.ShowDialog()
		End Sub

		Public Sub New()
			MyBase.New
			'
			' The Me.InitializeComponent call is required for Windows Forms designer support.
			'
			Me.InitializeComponent
			'
			' TODO : Add constructor code after InitializeComponents
			'
		End Sub

		#Region " Windows Forms Designer generated code "
		' This method is required for Windows Forms designer support.
		' Do not change the method contents inside the source code editor. The Forms designer might
		' not be able to load this method if it was changed manually.
		Private Sub InitializeComponent()
			Me.textBox1 = New System.Windows.Forms.TextBox
			Me.button1 = New System.Windows.Forms.Button
			Me.label1 = New System.Windows.Forms.Label
			Me.SuspendLayout
			'
			'textBox1
			'
			Me.textBox1.Location = New System.Drawing.Point(24, 32)
			Me.textBox1.Name = "textBox1"
			Me.textBox1.Size = New System.Drawing.Size(208, 20)
			Me.textBox1.TabIndex = 0
			Me.textBox1.Text = ""
			'
			'button1
			'
			Me.button1.Location = New System.Drawing.Point(24, 72)
			Me.button1.Name = "button1"
			Me.button1.Size = New System.Drawing.Size(160, 48)
			Me.button1.TabIndex = 1
			Me.button1.Text = "button1"
			AddHandler Me.button1.Click, AddressOf Me.Button1Click
			'
			'label1
			'
			Me.label1.Location = New System.Drawing.Point(16, 8)
			Me.label1.Name = "label1"
			Me.label1.Size = New System.Drawing.Size(200, 16)
			Me.label1.TabIndex = 2
			Me.label1.Text = "Kirjoita nimesi:"
			'
			'MainForm
			'
			Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
			Me.ClientSize = New System.Drawing.Size(256, 134)
			Me.Controls.Add(Me.label1)
			Me.Controls.Add(Me.button1)
			Me.Controls.Add(Me.textBox1)
			Me.Name = "MainForm"
			Me.Text = "MainForm"
			Me.ResumeLayout(false)
		End Sub
		#End Region

		Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
			MsgBox "Terve, " & textbox1.Text
		End Sub


	End Class

End Namespace

Mikähän syynä. SharpDevelop kyllä muuttaa sanan MsgBox siniseksi, elikkä se tunnistaa sen vissiin komennoksi. Lisäksi ohjelman alkuun tulee aina hirveesti tota koodia, onko tuo kaikki ihan pakollista?

Niko [07.08.2004 01:54:32]

#

MsgBox("Terve, " & textbox1.Text)

Kokeiles tuollein

ez [07.08.2004 10:09:48]

#

Eihän se kaikki ole pakollista, jos otat pois niin sulla ei ole enää sitä formia. Eli siinä luodaan formi. ite käytän messageboxin show metodia,eli: messagebox.show()

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta