I finished my Chat over LAN project and everything work great,
but i have problem here,I don't want users put their name every time they want to send msgs over LAN, I want the program use the PC name by default, so in chat section the PC name will appear automatically, Can someone help me in this!
& this is my code
Imports System.DirectoryServices
Imports System.Net
Imports System.IO
Imports System.Net.Sockets
Imports MSTSCLib
Public Class frmMain
Inherits System.Windows.Forms.Form
#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 TreeView1 As System.Windows.Forms.TreeView
Friend WithEvents txtPCName As System.Windows.Forms.TextBox
Friend WithEvents txtSend As System.Windows.Forms.TextBox
Friend WithEvents CmdSend As System.Windows.Forms.Button
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents txtPCIPadd As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents txtUsername As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents txtConversation As System.Windows.Forms.TextBox
Friend WithEvents txttempmsg As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))
Me.CmdSend = New System.Windows.Forms.Button()
Me.TreeView1 = New System.Windows.Forms.TreeView()
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.txtPCName = New System.Windows.Forms.TextBox()
Me.txtSend = New System.Windows.Forms.TextBox()
Me.txtPCIPadd = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.txtUsername = New System.Windows.Forms.TextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.txtConversation = New System.Windows.Forms.TextBox()
Me.txttempmsg = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'CmdSend
'
Me.CmdSend.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CmdSend.Location = New System.Drawing.Point(404, 265)
Me.CmdSend.Name = "CmdSend"
Me.CmdSend.Size = New System.Drawing.Size(55, 52)
Me.CmdSend.TabIndex = 0
Me.CmdSend.Text = "&Send"
'
'TreeView1
'
Me.TreeView1.ImageIndex = 0
Me.TreeView1.ImageList = Me.ImageList1
Me.TreeView1.Location = New System.Drawing.Point(291, 10)
Me.TreeView1.Name = "TreeView1"
Me.TreeView1.SelectedImageIndex = 0
Me.TreeView1.Size = New System.Drawing.Size(168, 234)
Me.TreeView1.TabIndex = 1
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
Me.ImageList1.Images.SetKeyName(0, "")
'
'txtPCName
'
Me.txtPCName.Location = New System.Drawing.Point(108, 34)
Me.txtPCName.Name = "txtPCName"
Me.txtPCName.ReadOnly = True
Me.txtPCName.Size = New System.Drawing.Size(136, 20)
Me.txtPCName.TabIndex = 2
'
'txtSend
'
Me.txtSend.Location = New System.Drawing.Point(12, 266)
Me.txtSend.Multiline = True
Me.txtSend.Name = "txtSend"
Me.txtSend.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtSend.Size = New System.Drawing.Size(386, 52)
Me.txtSend.TabIndex = 3
'
'txtPCIPadd
'
Me.txtPCIPadd.Location = New System.Drawing.Point(108, 58)
Me.txtPCIPadd.Name = "txtPCIPadd"
Me.txtPCIPadd.Size = New System.Drawing.Size(136, 20)
Me.txtPCIPadd.TabIndex = 6
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(13, 59)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(71, 15)
Me.Label2.TabIndex = 7
Me.Label2.Text = "IP Address :"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(12, 247)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(58, 15)
Me.Label3.TabIndex = 9
Me.Label3.Text = "Message"
'
'Timer1
'
'
'txtUsername
'
Me.txtUsername.Location = New System.Drawing.Point(108, 10)
Me.txtUsername.Name = "txtUsername"
Me.txtUsername.Size = New System.Drawing.Size(136, 20)
Me.txtUsername.TabIndex = 10
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(13, 14)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(70, 15)
Me.Label4.TabIndex = 11
Me.Label4.Text = "Your name:"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(13, 35)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(44, 15)
Me.Label5.TabIndex = 12
Me.Label5.Text = "Buddy:"
'
'txtConversation
'
Me.txtConversation.BackColor = System.Drawing.Color.White
Me.txtConversation.Location = New System.Drawing.Point(15, 84)
Me.txtConversation.Multiline = True
Me.txtConversation.Name = "txtConversation"
Me.txtConversation.ReadOnly = True
Me.txtConversation.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtConversation.Size = New System.Drawing.Size(270, 160)
Me.txtConversation.TabIndex = 14
'
'txttempmsg
'
Me.txttempmsg.Enabled = False
Me.txttempmsg.Location = New System.Drawing.Point(12, 342)
Me.txttempmsg.Multiline = True
Me.txttempmsg.Name = "txttempmsg"
Me.txttempmsg.Size = New System.Drawing.Size(212, 23)
Me.txttempmsg.TabIndex = 15
Me.txttempmsg.Visible = False
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.ButtonFace
Me.ClientSize = New System.Drawing.Size(471, 329)
Me.Controls.Add(Me.txttempmsg)
Me.Controls.Add(Me.txtConversation)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.txtUsername)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtPCIPadd)
Me.Controls.Add(Me.txtSend)
Me.Controls.Add(Me.txtPCName)
Me.Controls.Add(Me.TreeView1)
Me.Controls.Add(Me.CmdSend)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmMain"
Me.Text = "KiWi Messenger"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Dim listerner As New TcpListener(44444)
Dim client As TcpClient
Dim client2 As TcpClient
Dim message As String = ""
Dim tts As Object
Dim Sound As New System.Media.SoundPlayer()
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
listerner.Stop()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TextBox1.Selectionstart = TextBox1.TextLength
'TextBox1.ScrollToCaret()
Dim childEntry As DirectoryEntry
Dim ParentEntry As New DirectoryEntry()
Try
ParentEntry.Path = "WinNT:"
For Each childEntry In ParentEntry.Children
Dim newNode As New TreeNode(childEntry.Name)
Select Case childEntry.SchemaClassName
Case "Domain"
Dim ParentDomain As New TreeNode(childEntry.Name)
TreeView1.Nodes.AddRange(New TreeNode() {ParentDomain})
Dim SubChildEntry As DirectoryEntry
Dim SubParentEntry As New DirectoryEntry()
SubParentEntry.Path = "WinNT://" & childEntry.Name
For Each SubChildEntry In SubParentEntry.Children
Dim newNode1 As New TreeNode(SubChildEntry.Name)
Select Case SubChildEntry.SchemaClassName
Case "Computer"
ParentDomain.Nodes.Add(newNode1)
End Select
Next
End Select
Next
Catch Excep As Exception
MsgBox("Error While Reading Directories")
Finally
ParentEntry = Nothing
End Try
listerner.Start()
Timer1.Enabled = True
Timer1.Start()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSend.Click
' Shell("net send " & txtcomputer.Text & " " & txtmessage.Text)
Try
If txtPCIPadd.Text = "" Or txtUsername.Text = "" Or txtSend.Text = "" Then
MsgBox("Sorry Incomplete data")
Else
client = New TcpClient(txtPCIPadd.Text, 44444)
Dim writer As New StreamWriter(client.GetStream())
txttempmsg.Text = (txtSend.Text)
writer.Write(txtUsername.Text + " says: " + txtSend.Text)
txtConversation.Text = (txtConversation.Text + txtUsername.Text + " says: " + txttempmsg.Text + vbCrLf)
'txtmsg.Text="You:" + txtmessage.Text)
writer.Flush()
txtSend.Text = ""
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
txtPCName.Text = TreeView1.SelectedNode.Text
txtPCIPadd.Text = GetIPAddress(txtPCName.Text)
End Sub
Function GetIPAddress(ByVal CompName As String) As String
Dim oAddr As System.Net.IPAddress
Dim sAddr As String
Try
With System.Net.Dns.GetHostByName(CompName)
oAddr = New System.Net.IPAddress(.AddressList(0).Address)
sAddr = oAddr.ToString
End With
GetIPAddress = sAddr
Catch Excep As Exception
MsgBox(Excep.Message, MsgBoxStyle.OkOnly, "Lan Messenger")
Finally
End Try
End Function
Private Sub CmdPing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Shell("PING " & txtPCIPadd.Text)
End Sub
'Shell("net send ALL " & txtmessage.Text)
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
If listerner.Pending = True Then
message = ""
client = listerner.AcceptTcpClient
Dim reader As New StreamReader(client.GetStream())
While reader.Peek > -1
message = message + Convert.ToChar(reader.Read()).ToString
End While
Me.Focus()
txtConversation.Text = (txtConversation.Text + message + vbCrLf)
txtConversation.SelectionStart = txtConversation.TextLength
txtConversation.ScrollToCaret()
'txtmsg.Text="You:" + txtmessage.Text)
My.Computer.Audio.Play(My.Resources.alert, AudioPlayMode.Background)
Sound.Load()
Sound.Play()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Function c() As String
Throw New NotImplementedException
End Function
Private Sub txtUsername_TextChanged(sender As Object, e As EventArgs) Handles txtUsername.TextChanged
End Sub
End Class
You can retrieve the computer's name by using
System.Environment.MachineName
...of which you can assign to a variable, which in your instance would be:
txtUsername.Text = System.Environment.MachineName
Alternatively if you like doing things the long-winded way, you can use the WMI (Windows Management Instrumentation), as per se:
Dim details() As String = {"Name"}
Dim wmiItems As Dictionary(Of String, String)
wmiItems = WMI.GetWMISettingsDictionary("Win32_ComputerSystem", details)
For Each kvp As KeyValuePair(Of String, String) In wmiItems
txtUsername.Text = kvp.Value
Next
You can also get other system information in the same way, such as the make and model; refer to the documentation for this.
To use WMI you must refer to the System.Management library, place the following at the top of the code file:
Imports System.Management
Related
https://imgur.com/a/gTuKRnf
Video example in link above. (Short, 30 seconds)
listBox works fine until scrolling is needed.
When scrolling, listBox changes background, turns black, glitches out.
Have attempted OwnerDrawFixed mode but then listBox shows empty.
Has anyone else seen this before?
After Scroll:
After drag select/click:
Code Snippets:
[Form1 Designer.vb]
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
Me.PictureBox2 = New System.Windows.Forms.PictureBox()
Me.PictureBox3 = New System.Windows.Forms.PictureBox()
Me.PictureBox4 = New System.Windows.Forms.PictureBox()
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel()
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.Button2 = New System.Windows.Forms.Button()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox3, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox4, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 200
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Courier New", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
Me.TextBox1.Location = New System.Drawing.Point(12, 77)
Me.TextBox1.Margin = New System.Windows.Forms.Padding(6, 5, 6, 5)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(293, 31)
Me.TextBox1.TabIndex = 0
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Courier New", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
Me.Button1.Location = New System.Drawing.Point(153, 118)
Me.Button1.Margin = New System.Windows.Forms.Padding(6, 5, 6, 5)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(192, 35)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(12, 12)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(44, 44)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox1.TabIndex = 2
Me.PictureBox1.TabStop = False
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Courier New", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point)
Me.Label1.Location = New System.Drawing.Point(62, 23)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(283, 23)
Me.Label1.TabIndex = 3
Me.Label1.Text = "My App"
'
'ListBox1
'
Me.ListBox1.Font = New System.Drawing.Font("Courier New", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.ItemHeight = 16
Me.ListBox1.Location = New System.Drawing.Point(12, 161)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(333, 180)
Me.ListBox1.TabIndex = 4
'
'OpenFileDialog1
'
Me.OpenFileDialog1.AddExtension = False
Me.OpenFileDialog1.FileName = "OpenFileDialog1"
Me.OpenFileDialog1.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
Me.OpenFileDialog1.FilterIndex = 2
Me.OpenFileDialog1.RestoreDirectory = True
'
'PictureBox2
'
Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
Me.PictureBox2.Location = New System.Drawing.Point(314, 77)
Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(31, 31)
Me.PictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox2.TabIndex = 5
Me.PictureBox2.TabStop = False
'
'PictureBox3
'
Me.PictureBox3.Image = CType(resources.GetObject("PictureBox3.Image"), System.Drawing.Image)
Me.PictureBox3.Location = New System.Drawing.Point(12, 118)
Me.PictureBox3.Name = "PictureBox3"
Me.PictureBox3.Size = New System.Drawing.Size(31, 31)
Me.PictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox3.TabIndex = 6
Me.PictureBox3.TabStop = False
'
'PictureBox4
'
Me.PictureBox4.Image = CType(resources.GetObject("PictureBox4.Image"), System.Drawing.Image)
Me.PictureBox4.Location = New System.Drawing.Point(314, 355)
Me.PictureBox4.Name = "PictureBox4"
Me.PictureBox4.Size = New System.Drawing.Size(31, 31)
Me.PictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox4.TabIndex = 7
Me.PictureBox4.TabStop = False
'
'LinkLabel1
'
Me.LinkLabel1.AutoSize = True
Me.LinkLabel1.Font = New System.Drawing.Font("Courier New", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
Me.LinkLabel1.LinkColor = System.Drawing.Color.Black
Me.LinkLabel1.Location = New System.Drawing.Point(12, 373)
Me.LinkLabel1.Name = "LinkLabel1"
Me.LinkLabel1.Size = New System.Drawing.Size(126, 15)
Me.LinkLabel1.TabIndex = 8
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = "label"
Me.LinkLabel1.VisitedLinkColor = System.Drawing.Color.Black
'
'NotifyIcon1
'
Me.NotifyIcon1.Icon = CType(resources.GetObject("NotifyIcon1.Icon"), System.Drawing.Icon)
Me.NotifyIcon1.Text = "My App"
Me.NotifyIcon1.Visible = True
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Courier New", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
Me.Button2.Location = New System.Drawing.Point(153, 355)
Me.Button2.Margin = New System.Windows.Forms.Padding(6, 5, 6, 5)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(152, 31)
Me.Button2.TabIndex = 9
Me.Button2.Text = "Button"
Me.Button2.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(13.0!, 23.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(357, 397)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.LinkLabel1)
Me.Controls.Add(Me.PictureBox4)
Me.Controls.Add(Me.PictureBox3)
Me.Controls.Add(Me.PictureBox2)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Font = New System.Drawing.Font("Courier New", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "My App"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PictureBox3, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PictureBox4, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Timer1 As Timer
Friend WithEvents TextBox1 As TextBox
Friend WithEvents Button1 As Button
Friend WithEvents PictureBox1 As PictureBox
Friend WithEvents Label1 As Label
Friend WithEvents ListBox1 As ListBox
Friend WithEvents OpenFileDialog1 As OpenFileDialog
Friend WithEvents PictureBox2 As PictureBox
Friend WithEvents PictureBox3 As PictureBox
Friend WithEvents PictureBox4 As PictureBox
Friend WithEvents LinkLabel1 As LinkLabel
Friend WithEvents NotifyIcon1 As NotifyIcon
Friend WithEvents Button2 As Button
End Class
[Form1.vb]
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If System.IO.File.Exists("myfile.txt") Then
Dim lines = File.ReadAllLines("myfile.txt")
ListBox1.Items.Clear()
ListBox1.Items.AddRange(lines)
End If
End Sub
Example of 'myfile.txt' contents:
iexplore1
iexplore2
iexplore3
iexplore4
... [And so on]
I was told to edit the program up here, so here is small program that shows what I am trying to accomplish (learn)
I am using the screen.Bounds as you suggested, but the problem is still that the mouse gets it's location only when it is within the form. Outside of the form the mouse has no clue where it is, and therefore cant tell me the color at its mouse position.
I feel I'm so close to getting this to work...
Public Class Form10
'Sample Code
'Needs 2 Textboxes, names txtStatic, txtMouse
'Needs 2 Pictureboxes, names PBStatic, PBMouse
'Needs Timer1 set to 1000
'Goal is to show pixelcolor of screen under
'form's corner, top/left at Point(450,74) "named STATIC"
'and show color of Screen Pixel when mouse is clicked
'anywhere on Screen "named MOUSE"
Dim ScreenX, ScreenY As Integer
Dim SColor, MColor As Color
Dim MouseLoc, StaticLoc As Point
Private Sub Form10_Load(sender As Object, e As EventArgs) _
Handles Me.Load
Me.Location = New Point(450, 75)
StaticLoc = Me.Location
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ScreenX = My.Computer.Screen.Bounds.Width
ScreenY = My.Computer.Screen.Bounds.Height
Dim bm As New Bitmap(ScreenX, ScreenY)
SColor = GetPixColor(StaticLoc)
MColor = GetPixColor(MouseLoc)
TxtStatic.Text = StaticLoc.ToString
TxtMouse.Text = MouseLoc.ToString
PBStatic.BackColor = SColor
PBMouse.BackColor = MColor
End Sub
Function GetPixColor(ByVal Location As Point) As Color
Using b As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(b)
g.CopyFromScreen(Location, Point.Empty, New Drawing.Size(1, 1))
End Using
Return b.GetPixel(0, 0)
End Using
End Function
Private Sub Form10_MouseMove(sender As Object,
e As MouseEventArgs) _
Handles Me.MouseMove
If e.Button = MouseButtons.Left Then
Dim x1, y1 As Integer
x1 = e.Location.X - mouseloc.X
y1 = e.Location.Y - mouseloc.Y
Me.Location = New Point(Me.Location.X + x1,
Me.Location.Y + y1)
End If
End Sub
Private Sub Form10_MouseClick(sender As Object,
e As MouseEventArgs) _
Handles Me.MouseClick
MouseLoc = e.Location
End Sub
End Class
HERE IS THE DESIGNER IN CASE SOMETHING IS WRONG THERE TOO !!
_
Partial Class Form10
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.PBMouse = New System.Windows.Forms.PictureBox()
Me.TxtMouse = New System.Windows.Forms.TextBox()
Me.TxtStatic = New System.Windows.Forms.TextBox()
Me.PBStatic = New System.Windows.Forms.PictureBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
CType(Me.PBMouse, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PBStatic, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Timer1
'
Me.Timer1.Interval = 1000
'
'PBMouse
'
Me.PBMouse.Location = New System.Drawing.Point(35, 341)
Me.PBMouse.Name = "PBMouse"
Me.PBMouse.Size = New System.Drawing.Size(337, 50)
Me.PBMouse.TabIndex = 8
Me.PBMouse.TabStop = False
'
'TxtMouse
'
Me.TxtMouse.Font = New System.Drawing.Font("Segoe UI", 16.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TxtMouse.Location = New System.Drawing.Point(35, 260)
Me.TxtMouse.Name = "TxtMouse"
Me.TxtMouse.Size = New System.Drawing.Size(337, 64)
Me.TxtMouse.TabIndex = 7
'
'TxtStatic
'
Me.TxtStatic.Font = New System.Drawing.Font("Segoe UI", 16.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TxtStatic.Location = New System.Drawing.Point(35, 109)
Me.TxtStatic.Name = "TxtStatic"
Me.TxtStatic.Size = New System.Drawing.Size(337, 64)
Me.TxtStatic.TabIndex = 6
'
'PBStatic
'
Me.PBStatic.Location = New System.Drawing.Point(35, 43)
Me.PBStatic.Name = "PBStatic"
Me.PBStatic.Size = New System.Drawing.Size(337, 50)
Me.PBStatic.TabIndex = 5
Me.PBStatic.TabStop = False
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(39, 14)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 29)
Me.Label1.TabIndex = 9
Me.Label1.Text = "Static"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(39, 224)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(128, 29)
Me.Label3.TabIndex = 11
Me.Label3.Text = "MousePos"
'
'Form10
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(12.0!, 25.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(412, 450)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.PBMouse)
Me.Controls.Add(Me.TxtMouse)
Me.Controls.Add(Me.TxtStatic)
Me.Controls.Add(Me.PBStatic)
Me.Name = "Form10"
Me.Text = "Form10"
Me.TopMost = True
CType(Me.PBMouse, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PBStatic, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Timer1 As Timer
Friend WithEvents PBMouse As PictureBox
Friend WithEvents TxtMouse As TextBox
Friend WithEvents TxtStatic As TextBox
Friend WithEvents PBStatic As PictureBox
Friend WithEvents Label1 As Label
Friend WithEvents Label3 As Label
End Class
I'm new to Visual Basic.NET and I've been trying to make this simple application. It's a tax calculator.
Two-dimensional arrays are a bit... well not easy for me to grasp yet. So my question is: can you take a look at my code and give me hints on how to solve this issue?
When I run the code in the Labelbox I get a result of 0.00
Public Class PerrytownForm
Inherits System.Windows.Forms.Form
#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
Friend WithEvents IdFwtLabel As System.Windows.Forms.Label
Friend WithEvents FwtLabel As System.Windows.Forms.Label
Friend WithEvents CalculateButton As System.Windows.Forms.Button
Friend WithEvents ExitButton As System.Windows.Forms.Button
Friend WithEvents StatusGroupBox As System.Windows.Forms.GroupBox
Friend WithEvents MarriedRadioButton As System.Windows.Forms.RadioButton
Friend WithEvents SingleRadioButton As System.Windows.Forms.RadioButton
Friend WithEvents IdTaxableLabel As System.Windows.Forms.Label
Friend WithEvents TaxableTextBox As System.Windows.Forms.TextBox
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'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.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.IdTaxableLabel = New System.Windows.Forms.Label()
Me.StatusGroupBox = New System.Windows.Forms.GroupBox()
Me.MarriedRadioButton = New System.Windows.Forms.RadioButton()
Me.SingleRadioButton = New System.Windows.Forms.RadioButton()
Me.TaxableTextBox = New System.Windows.Forms.TextBox()
Me.IdFwtLabel = New System.Windows.Forms.Label()
Me.FwtLabel = New System.Windows.Forms.Label()
Me.CalculateButton = New System.Windows.Forms.Button()
Me.ExitButton = New System.Windows.Forms.Button()
Me.StatusGroupBox.SuspendLayout()
Me.SuspendLayout()
'
'IdTaxableLabel
'
Me.IdTaxableLabel.AutoSize = True
Me.IdTaxableLabel.Location = New System.Drawing.Point(24, 24)
Me.IdTaxableLabel.Name = "IdTaxableLabel"
Me.IdTaxableLabel.Size = New System.Drawing.Size(99, 16)
Me.IdTaxableLabel.TabIndex = 0
Me.IdTaxableLabel.Text = "&Taxable wages:"
'
'StatusGroupBox
'
Me.StatusGroupBox.Controls.Add(Me.MarriedRadioButton)
Me.StatusGroupBox.Controls.Add(Me.SingleRadioButton)
Me.StatusGroupBox.Location = New System.Drawing.Point(184, 24)
Me.StatusGroupBox.Name = "StatusGroupBox"
Me.StatusGroupBox.Size = New System.Drawing.Size(95, 88)
Me.StatusGroupBox.TabIndex = 2
Me.StatusGroupBox.TabStop = False
Me.StatusGroupBox.Text = "Status"
'
'MarriedRadioButton
'
Me.MarriedRadioButton.Checked = True
Me.MarriedRadioButton.Location = New System.Drawing.Point(8, 21)
Me.MarriedRadioButton.Name = "MarriedRadioButton"
Me.MarriedRadioButton.Size = New System.Drawing.Size(80, 24)
Me.MarriedRadioButton.TabIndex = 0
Me.MarriedRadioButton.TabStop = True
Me.MarriedRadioButton.Text = "&Married"
'
'SingleRadioButton
'
Me.SingleRadioButton.Location = New System.Drawing.Point(8, 50)
Me.SingleRadioButton.Name = "SingleRadioButton"
Me.SingleRadioButton.Size = New System.Drawing.Size(80, 24)
Me.SingleRadioButton.TabIndex = 1
Me.SingleRadioButton.Text = "&Single"
'
'TaxableTextBox
'
Me.TaxableTextBox.Location = New System.Drawing.Point(24, 40)
Me.TaxableTextBox.Name = "TaxableTextBox"
Me.TaxableTextBox.Size = New System.Drawing.Size(136, 23)
Me.TaxableTextBox.TabIndex = 1
'
'IdFwtLabel
'
Me.IdFwtLabel.AutoSize = True
Me.IdFwtLabel.Location = New System.Drawing.Point(24, 80)
Me.IdFwtLabel.Name = "IdFwtLabel"
Me.IdFwtLabel.Size = New System.Drawing.Size(146, 16)
Me.IdFwtLabel.TabIndex = 5
Me.IdFwtLabel.Text = "Federal withholding tax:"
'
'FwtLabel
'
Me.FwtLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.FwtLabel.Location = New System.Drawing.Point(24, 96)
Me.FwtLabel.Name = "FwtLabel"
Me.FwtLabel.Size = New System.Drawing.Size(136, 23)
Me.FwtLabel.TabIndex = 6
Me.FwtLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'CalculateButton
'
Me.CalculateButton.Location = New System.Drawing.Point(184, 120)
Me.CalculateButton.Name = "CalculateButton"
Me.CalculateButton.Size = New System.Drawing.Size(96, 25)
Me.CalculateButton.TabIndex = 3
Me.CalculateButton.Text = "&Calculate Tax"
'
'ExitButton
'
Me.ExitButton.Location = New System.Drawing.Point(184, 152)
Me.ExitButton.Name = "ExitButton"
Me.ExitButton.Size = New System.Drawing.Size(96, 25)
Me.ExitButton.TabIndex = 4
Me.ExitButton.Text = "E&xit"
'
'PerrytownForm
'
Me.AcceptButton = Me.CalculateButton
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 16)
Me.ClientSize = New System.Drawing.Size(312, 205)
Me.Controls.Add(Me.StatusGroupBox)
Me.Controls.Add(Me.ExitButton)
Me.Controls.Add(Me.CalculateButton)
Me.Controls.Add(Me.FwtLabel)
Me.Controls.Add(Me.IdFwtLabel)
Me.Controls.Add(Me.TaxableTextBox)
Me.Controls.Add(Me.IdTaxableLabel)
Me.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Name = "PerrytownForm"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Perrytown Gift Shop"
Me.StatusGroupBox.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
'declare form-level arrays
Private msngSingle(,) As Single = {{51, 0, 0, 0},
{552, 0, 0.15, 51},
{1196, 75.15, 0.28, 552},
{2662, 255.47, 0.31, 1196},
{5750, 709.93, 0.36, 2662},
{99999, 1821.61, 0.396, 5750}}
Private msngMarried(,) As Single = {{124, 0, 0, 0},
{960, 0, 0.15, 124},
{2023, 124.4, 0.28, 960},
{3292, 423.04, 0.31, 2023},
{5809, 816.43, 0.36, 3292},
{99999, 1722.55, 0.396, 5809}}
Private Sub ExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub TaxableTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TaxableTextBox.Enter
Me.TaxableTextBox.SelectAll()
End Sub
Private Sub ClearLabels(ByVal sender As Object, ByVal e As System.EventArgs) Handles MarriedRadioButton.Click, SingleRadioButton.Click, TaxableTextBox.TextChanged
Me.FwtLabel.Text = ""
End Sub
Private Sub CalculateButton_Click(sender As Object, e As EventArgs) Handles CalculateButton.Click
Dim sngTaxTable(5, 3) As Single
Dim sngTaxable, sngFwt As Single, intRow As Integer
Dim blnFound As Boolean
'assign taxable wages to a variable
sngTaxable = Val(Me.TaxableTextBox.Text)
'determine appropriate array
If Me.SingleRadioButton.Checked = True Then
sngTaxable = msngSingle
Else
sngTaxable = msngMarried
End If
'search for taxable wages in the first column in the array
Do While intRow < 6 AndAlso blnFound = False
If sngTaxable <= sngTaxTable(intRow, 0) Then
'calculate the fwt
sngFwt = sngTaxTable(intRow, 1) _
+ sngTaxTable(intRow, 2) _
* (sngTaxable - sngTaxTable(intRow, 3))
blnFound = True
Else
intRow = intRow + 1
End If
Loop
'display the fwt
Me.FwtLabel.Text = Format(sngFwt, "currency")
End Sub
End Class
I tried the code for myself and found some mistake: You forgot the letter "T"
If Me.SingleRadioButton.Checked = True Then
sngTaxable = msngSingle
Else
sngTaxable = msngMarried
End If
needs to be
If Me.SingleRadioButton.Checked = True Then
sngTaxTable = msngSingle
Else
sngTaxTable = msngMarried
End If
If I change this, the code will work and give some results, if I try to enter some numbers.
If they are too little or big, the program doesn't do anything. I don't know if this is intentional, but maybe a little error output (MsgBox etc) could be nice.
I have a datagrid on a form named frmTeacherload and suddenly when I run the code it came up with this error Value of type 'String' cannot be converted to 'System.Windows.Forms.DataGridViewTextBoxColumn'. on the designer of vb. Here is my code guys I hope you can help me thanks in advance
designer code
_
Partial Class frmTeacherload
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.lblBack = New System.Windows.Forms.LinkLabel()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.DataGridView2 = New System.Windows.Forms.DataGridView()
Me.Name = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TblteacherloadDataSet2 = New WindowsApplication1.tblteacherloadDataSet2()
Me.TblteacherloadDataSet1 = New WindowsApplication1.tblteacherloadDataSet1()
Me.TblteacherloadTableAdapter = New WindowsApplication1.tblteacherloadDataSet1TableAdapters.tblteacherloadTableAdapter()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.TextBox5 = New System.Windows.Forms.TextBox()
Me.Label8 = New System.Windows.Forms.Label()
Me.TextBox6 = New System.Windows.Forms.TextBox()
Me.Label9 = New System.Windows.Forms.Label()
Me.TextBox7 = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.TblteacherloadTableAdapter1 = New WindowsApplication1.tblteacherloadDataSet2TableAdapters.tblteacherloadTableAdapter()
Me.TblteacherloadDataSet3 = New WindowsApplication1.tblteacherloadDataSet3()
Me.BindingSource1 = New System.Windows.Forms.BindingSource(Me.components)
Me.TblteacherloadTableAdapter2 = New WindowsApplication1.tblteacherloadDataSet3TableAdapters.tblteacherloadTableAdapter()
Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.NameDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.DataGridViewTextBoxColumn4 = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.DataGridViewTextBoxColumn5 = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.DataGridViewTextBoxColumn6 = New System.Windows.Forms.DataGridViewTextBoxColumn()
CType(Me.DataGridView2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.TblteacherloadDataSet2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.TblteacherloadDataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.TblteacherloadDataSet3, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.BindingSource1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Lucida Calligraphy", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(610, 18)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(217, 31)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Teacher's Load"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(22, 74)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(125, 13)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Choose Teachers Name:"
'
'ComboBox1
'
Me.ComboBox1.FormattingEnabled = True
Me.ComboBox1.Location = New System.Drawing.Point(149, 70)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(121, 21)
Me.ComboBox1.TabIndex = 2
'
'lblBack
'
Me.lblBack.AutoSize = True
Me.lblBack.Location = New System.Drawing.Point(22, 30)
Me.lblBack.Name = "lblBack"
Me.lblBack.Size = New System.Drawing.Size(50, 13)
Me.lblBack.TabIndex = 94
Me.lblBack.TabStop = True
Me.lblBack.Text = "<<<Back"
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.Color.Black
Me.Panel1.Location = New System.Drawing.Point(549, 52)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(272, 10)
Me.Panel1.TabIndex = 95
'
'DataGridView2
'
Me.DataGridView2.AutoGenerateColumns = False
Me.DataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.DataGridView2.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Name, Me.DataGridViewTextBoxColumn1, Me.NameDataGridViewTextBoxColumn, Me.DataGridViewTextBoxColumn2, Me.DataGridViewTextBoxColumn3, Me.DataGridViewTextBoxColumn4, Me.DataGridViewTextBoxColumn5, Me.DataGridViewTextBoxColumn6})
Me.DataGridView2.DataSource = Me.BindingSource1
Me.DataGridView2.Location = New System.Drawing.Point(45, 97)
Me.DataGridView2.Name = "DataGridView2"
Me.DataGridView2.Size = New System.Drawing.Size(753, 178)
Me.DataGridView2.TabIndex = 96
'
'Name
'
Me.Name.DataPropertyName = "Name"
Me.Name.HeaderText = "Name"
Me.Name.Name = "Name"
'
'TblteacherloadDataSet2
'
Me.TblteacherloadDataSet2.DataSetName = "tblteacherloadDataSet2"
Me.TblteacherloadDataSet2.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
'
'TblteacherloadDataSet1
'
Me.TblteacherloadDataSet1.DataSetName = "tblteacherloadDataSet1"
Me.TblteacherloadDataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
'
'TblteacherloadTableAdapter
'
Me.TblteacherloadTableAdapter.ClearBeforeFill = True
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(123, 303)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(100, 20)
Me.TextBox1.TabIndex = 97
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(33, 306)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(18, 13)
Me.Label3.TabIndex = 98
Me.Label3.Text = "ID"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(33, 351)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(85, 13)
Me.Label4.TabIndex = 100
Me.Label4.Text = "Teacher's Name"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(123, 348)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(100, 20)
Me.TextBox2.TabIndex = 99
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(337, 310)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(43, 13)
Me.Label5.TabIndex = 104
Me.Label5.Text = "Subject"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(123, 393)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(100, 20)
Me.TextBox3.TabIndex = 103
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(33, 394)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(43, 13)
Me.Label6.TabIndex = 102
Me.Label6.Text = "Section"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(427, 303)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(100, 20)
Me.TextBox4.TabIndex = 101
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(337, 393)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(30, 13)
Me.Label7.TabIndex = 108
Me.Label7.Text = "Time"
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(427, 345)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(100, 20)
Me.TextBox5.TabIndex = 107
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(337, 348)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(26, 13)
Me.Label8.TabIndex = 106
Me.Label8.Text = "Day"
'
'TextBox6
'
Me.TextBox6.Location = New System.Drawing.Point(427, 394)
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.Size = New System.Drawing.Size(100, 20)
Me.TextBox6.TabIndex = 105
'
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.Location = New System.Drawing.Point(588, 306)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(35, 13)
Me.Label9.TabIndex = 112
Me.Label9.Text = "Room"
'
'TextBox7
'
Me.TextBox7.Location = New System.Drawing.Point(678, 303)
Me.TextBox7.Name = "TextBox7"
Me.TextBox7.Size = New System.Drawing.Size(100, 20)
Me.TextBox7.TabIndex = 111
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(591, 435)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(94, 30)
Me.Button1.TabIndex = 113
Me.Button1.Text = "SUBMIT"
Me.Button1.UseVisualStyleBackColor = True
'
'TblteacherloadTableAdapter1
'
Me.TblteacherloadTableAdapter1.ClearBeforeFill = True
'
'TblteacherloadDataSet3
'
Me.TblteacherloadDataSet3.DataSetName = "tblteacherloadDataSet3"
Me.TblteacherloadDataSet3.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
'
'BindingSource1
'
Me.BindingSource1.DataMember = "tblteacherload"
Me.BindingSource1.DataSource = Me.TblteacherloadDataSet3
'
'TblteacherloadTableAdapter2
'
Me.TblteacherloadTableAdapter2.ClearBeforeFill = True
'
'DataGridViewTextBoxColumn1
'
Me.DataGridViewTextBoxColumn1.DataPropertyName = "ID"
Me.DataGridViewTextBoxColumn1.HeaderText = "ID"
Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1"
'
'NameDataGridViewTextBoxColumn
'
Me.NameDataGridViewTextBoxColumn.DataPropertyName = "Name"
Me.NameDataGridViewTextBoxColumn.HeaderText = "Name"
Me.NameDataGridViewTextBoxColumn.Name = "NameDataGridViewTextBoxColumn"
'
'DataGridViewTextBoxColumn2
'
Me.DataGridViewTextBoxColumn2.DataPropertyName = "Section"
Me.DataGridViewTextBoxColumn2.HeaderText = "Section"
Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2"
'
'DataGridViewTextBoxColumn3
'
Me.DataGridViewTextBoxColumn3.DataPropertyName = "Subject"
Me.DataGridViewTextBoxColumn3.HeaderText = "Subject"
Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3"
'
'DataGridViewTextBoxColumn4
'
Me.DataGridViewTextBoxColumn4.DataPropertyName = "Day"
Me.DataGridViewTextBoxColumn4.HeaderText = "Day"
Me.DataGridViewTextBoxColumn4.Name = "DataGridViewTextBoxColumn4"
'
'DataGridViewTextBoxColumn5
'
Me.DataGridViewTextBoxColumn5.DataPropertyName = "Time"
Me.DataGridViewTextBoxColumn5.HeaderText = "Time"
Me.DataGridViewTextBoxColumn5.Name = "DataGridViewTextBoxColumn5"
'
'DataGridViewTextBoxColumn6
'
Me.DataGridViewTextBoxColumn6.DataPropertyName = "Room"
Me.DataGridViewTextBoxColumn6.HeaderText = "Room"
Me.DataGridViewTextBoxColumn6.Name = "DataGridViewTextBoxColumn6"
'
'frmTeacherload
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(839, 494)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.TextBox7)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.DataGridView2)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.lblBack)
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "frmTeacherload"
Me.Text = "First Books Learning Center"
CType(Me.DataGridView2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.TblteacherloadDataSet2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.TblteacherloadDataSet1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.TblteacherloadDataSet3, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.BindingSource1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents frmTeacherload As System.Windows.Forms.Form
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents lblBack As System.Windows.Forms.LinkLabel
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents DataGridView2 As System.Windows.Forms.DataGridView
Friend WithEvents TblteacherloadDataSet1 As WindowsApplication1.tblteacherloadDataSet1
Friend WithEvents TblteacherloadBindingSource As System.Windows.Forms.BindingSource
Friend WithEvents TblteacherloadTableAdapter As WindowsApplication1.tblteacherloadDataSet1TableAdapters.tblteacherloadTableAdapter
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TblteacherloadDataSet2 As WindowsApplication1.tblteacherloadDataSet2
Friend WithEvents TblteacherloadBindingSource1 As System.Windows.Forms.BindingSource
Friend WithEvents TblteacherloadTableAdapter1 As WindowsApplication1.tblteacherloadDataSet2TableAdapters.tblteacherloadTableAdapter
Friend WithEvents IDDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Shadows WithEvents Name As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents SectionDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents SubjectDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents DayDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TimeDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents RoomDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TblteacherloadDataSet3 As WindowsApplication1.tblteacherloadDataSet3
Friend WithEvents BindingSource1 As System.Windows.Forms.BindingSource
Friend WithEvents TblteacherloadTableAdapter2 As WindowsApplication1.tblteacherloadDataSet3TableAdapters.tblteacherloadTableAdapter
Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents NameDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents DataGridViewTextBoxColumn2 As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents DataGridViewTextBoxColumn4 As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents DataGridViewTextBoxColumn5 As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents DataGridViewTextBoxColumn6 As System.Windows.Forms.DataGridViewTextBoxColumn
End Class
frmTeacherload
Public Class frmTeacherload
Dim query As String
Dim y As String = "Provider=Microsoft.ACE.OLEDB.12.0;Password='';User ID=;Data Source='" & Application.StartupPath & "/tblteacherload.accdb';"
Dim database As New clsDatabase.OleDBase(y)
Private Sub lblBack_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lblBack.LinkClicked
frmEnrollment.Show()
Me.Hide()
End Sub
Private Sub frmTeacherload_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'TblteacherloadDataSet3.tblteacherload' table. You can move, or remove it, as needed.
Me.TblteacherloadTableAdapter2.Fill(Me.TblteacherloadDataSet3.tblteacherload)
'TODO: This line of code loads data into the 'TblteacherloadDataSet2.tblteacherload' table. You can move, or remove it, as needed.
Me.TblteacherloadTableAdapter1.Fill(Me.TblteacherloadDataSet2.tblteacherload)
'TODO: This line of code loads data into the 'TblteacherloadDataSet1.tblteacherload' table. You can move, or remove it, as needed.
Me.TblteacherloadTableAdapter.Fill(Me.TblteacherloadDataSet1.tblteacherload)
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub fillDataGridView2()
Try
Cursor = Cursors.WaitCursor
'=================================================
'eto lang naman ung mahalaga-> para ilabas sa datagridview ung laman ng table
query = "Select * From tblteacherload;" ' malamang eto ung query
database.ToDataGrid(Me.DataGridView2, query) ' eto naman ung pang-execute
'=================================================
Cursor = Cursors.Default
Catch ex As Exception
MessageBox.Show("Connection Failed")
Cursor = Cursors.Default
End Try
End Sub
'eto ung mga query, dapat maayos at tama lahat ng nakasulat., pag hindi error lalabas, magingat ka sa pag-dedeclare, tignan mo mabuti ung query para tama
Private Sub add_save()
query = "INSERT INTO `tblteacherload`(`ID`, `Name`, `Section`, `Subject`, `Day`,`Time`,`Room`) VALUES ('" _
& TextBox1.Text & "', '" & TextBox2.Text & "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text & "', , '" & TextBox7.Text & "');"
database.ToDataGrid(Me.DataGridView2, query)
clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
add_save()
MsgBox("Saved Successfully", MsgBoxStyle.Information, "")
End Sub
Private Sub clear()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
End Sub
Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
Me.TblteacherloadTableAdapter1.FillBy(Me.TblteacherloadDataSet2.tblteacherload)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
End Class
The error is in this line
Me.Name = New System.Windows.Forms.DataGridViewTextBoxColumn()
You have a column on your DataGridView control named "Name" and the form has a property named "Name".
When the designer finds the line above it thinks that that's the property Name of the form.
If you look down the designer code you'll find this other line
Me.Name = "frmTeacherload"
To fix that error you have to rename the column.
I made a new project and added the form1.vb and form1.desinger.vb form another project to the new project(was working at another computer and saved the two source to usb moved to home computer and thought i could just add the two source files from my usb to the project and it would work.) now my design view does not showing any buttons or labels; but the code is still there and when i run the program it still works(i can see the form with all controls). I am unable though to use design view to update the properties of the controls. Would like to be able to see buttons and labels back in design view to edit.
here is the form1.designer.vb code:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.txtAdultSold = New System.Windows.Forms.TextBox()
Me.txtAdultPrice = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.txtChildSold = New System.Windows.Forms.TextBox()
Me.txtChildPrice = New System.Windows.Forms.TextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
Me.txtTotalGross = New System.Windows.Forms.TextBox()
Me.txtChildSalesGross = New System.Windows.Forms.TextBox()
Me.txtAdultSalesGross = New System.Windows.Forms.TextBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.GroupBox4 = New System.Windows.Forms.GroupBox()
Me.txtTotalNet = New System.Windows.Forms.TextBox()
Me.txtChildSalesNet = New System.Windows.Forms.TextBox()
Me.txtAdultSalesNet = New System.Windows.Forms.TextBox()
Me.Label10 = New System.Windows.Forms.Label()
Me.Label9 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.btnCalucateTicketRev = New System.Windows.Forms.Button()
Me.btnClear = New System.Windows.Forms.Button()
Me.btnExit = New System.Windows.Forms.Button()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.GroupBox3.SuspendLayout()
Me.GroupBox4.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.AutoSize = True
Me.GroupBox1.Controls.Add(Me.txtAdultSold)
Me.GroupBox1.Controls.Add(Me.txtAdultPrice)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox1.Location = New System.Drawing.Point(22, 22)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(236, 122)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Adult Ticket Sales"
'
'txtAdultSold
'
Me.txtAdultSold.Location = New System.Drawing.Point(114, 59)
Me.txtAdultSold.Name = "txtAdultSold"
Me.txtAdultSold.Size = New System.Drawing.Size(100, 20)
Me.txtAdultSold.TabIndex = 2
'
'txtAdultPrice
'
Me.txtAdultPrice.Location = New System.Drawing.Point(114, 27)
Me.txtAdultPrice.Name = "txtAdultPrice"
Me.txtAdultPrice.Size = New System.Drawing.Size(100, 20)
Me.txtAdultPrice.TabIndex = 1
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label2.Location = New System.Drawing.Point(38, 59)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(69, 13)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Tickets Sold:"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label1.Location = New System.Drawing.Point(22, 27)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(85, 13)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Price per Ticket:"
'
'GroupBox2
'
Me.GroupBox2.AutoSize = True
Me.GroupBox2.Controls.Add(Me.txtChildSold)
Me.GroupBox2.Controls.Add(Me.txtChildPrice)
Me.GroupBox2.Controls.Add(Me.Label4)
Me.GroupBox2.Controls.Add(Me.Label3)
Me.GroupBox2.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox2.Location = New System.Drawing.Point(274, 22)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(234, 122)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Child Ticket Sales"
'
'txtChildSold
'
Me.txtChildSold.Location = New System.Drawing.Point(108, 51)
Me.txtChildSold.Name = "txtChildSold"
Me.txtChildSold.Size = New System.Drawing.Size(100, 20)
Me.txtChildSold.TabIndex = 4
'
'txtChildPrice
'
Me.txtChildPrice.Location = New System.Drawing.Point(108, 20)
Me.txtChildPrice.Name = "txtChildPrice"
Me.txtChildPrice.Size = New System.Drawing.Size(100, 20)
Me.txtChildPrice.TabIndex = 3
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label4.Location = New System.Drawing.Point(31, 58)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(69, 13)
Me.Label4.TabIndex = 1
Me.Label4.Text = "Tickets Sold:"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label3.Location = New System.Drawing.Point(15, 20)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(85, 13)
Me.Label3.TabIndex = 0
Me.Label3.Text = "Price per Ticket:"
'
'GroupBox3
'
Me.GroupBox3.AutoSize = True
Me.GroupBox3.Controls.Add(Me.txtTotalGross)
Me.GroupBox3.Controls.Add(Me.txtChildSalesGross)
Me.GroupBox3.Controls.Add(Me.txtAdultSalesGross)
Me.GroupBox3.Controls.Add(Me.Label7)
Me.GroupBox3.Controls.Add(Me.Label6)
Me.GroupBox3.Controls.Add(Me.Label5)
Me.GroupBox3.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox3.Location = New System.Drawing.Point(22, 150)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(236, 152)
Me.GroupBox3.TabIndex = 2
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "Gross Ticket Revenue"
'
'txtTotalGross
'
Me.txtTotalGross.Location = New System.Drawing.Point(120, 99)
Me.txtTotalGross.Name = "txtTotalGross"
Me.txtTotalGross.ReadOnly = True
Me.txtTotalGross.Size = New System.Drawing.Size(100, 20)
Me.txtTotalGross.TabIndex = 5
'
'txtChildSalesGross
'
Me.txtChildSalesGross.Location = New System.Drawing.Point(117, 59)
Me.txtChildSalesGross.Name = "txtChildSalesGross"
Me.txtChildSalesGross.ReadOnly = True
Me.txtChildSalesGross.Size = New System.Drawing.Size(100, 20)
Me.txtChildSalesGross.TabIndex = 4
'
'txtAdultSalesGross
'
Me.txtAdultSalesGross.Location = New System.Drawing.Point(117, 21)
Me.txtAdultSalesGross.Name = "txtAdultSalesGross"
Me.txtAdultSalesGross.ReadOnly = True
Me.txtAdultSalesGross.Size = New System.Drawing.Size(100, 20)
Me.txtAdultSalesGross.TabIndex = 3
'
'Label7
'
Me.Label7.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label7.ImageAlign = System.Drawing.ContentAlignment.TopLeft
Me.Label7.Location = New System.Drawing.Point(6, 98)
Me.Label7.Name = "Label7"
Me.Label7.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label7.Size = New System.Drawing.Size(110, 38)
Me.Label7.TabIndex = 2
Me.Label7.Text = "Total Gross Revenue :for Ticket Sales"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label6.Location = New System.Drawing.Point(19, 59)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(95, 13)
Me.Label6.TabIndex = 1
Me.Label6.Text = "Child Ticket Sales:"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label5.Location = New System.Drawing.Point(16, 20)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(96, 13)
Me.Label5.TabIndex = 0
Me.Label5.Text = "Adult Ticket Sales:"
'
'GroupBox4
'
Me.GroupBox4.AutoSize = True
Me.GroupBox4.Controls.Add(Me.txtTotalNet)
Me.GroupBox4.Controls.Add(Me.txtChildSalesNet)
Me.GroupBox4.Controls.Add(Me.txtAdultSalesNet)
Me.GroupBox4.Controls.Add(Me.Label10)
Me.GroupBox4.Controls.Add(Me.Label9)
Me.GroupBox4.Controls.Add(Me.Label8)
Me.GroupBox4.ForeColor = System.Drawing.SystemColors.HotTrack
Me.GroupBox4.Location = New System.Drawing.Point(274, 150)
Me.GroupBox4.Name = "GroupBox4"
Me.GroupBox4.Size = New System.Drawing.Size(234, 137)
Me.GroupBox4.TabIndex = 3
Me.GroupBox4.TabStop = False
Me.GroupBox4.Text = "Net Ticket Revenue"
'
'txtTotalNet
'
Me.txtTotalNet.Location = New System.Drawing.Point(123, 91)
Me.txtTotalNet.Name = "txtTotalNet"
Me.txtTotalNet.ReadOnly = True
Me.txtTotalNet.Size = New System.Drawing.Size(100, 20)
Me.txtTotalNet.TabIndex = 5
'
'txtChildSalesNet
'
Me.txtChildSalesNet.Location = New System.Drawing.Point(123, 59)
Me.txtChildSalesNet.Name = "txtChildSalesNet"
Me.txtChildSalesNet.ReadOnly = True
Me.txtChildSalesNet.Size = New System.Drawing.Size(100, 20)
Me.txtChildSalesNet.TabIndex = 4
'
'txtAdultSalesNet
'
Me.txtAdultSalesNet.Location = New System.Drawing.Point(123, 19)
Me.txtAdultSalesNet.Name = "txtAdultSalesNet"
Me.txtAdultSalesNet.ReadOnly = True
Me.txtAdultSalesNet.Size = New System.Drawing.Size(100, 20)
Me.txtAdultSalesNet.TabIndex = 3
'
'Label10
'
Me.Label10.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label10.Location = New System.Drawing.Point(6, 91)
Me.Label10.Name = "Label10"
Me.Label10.RightToLeft = System.Windows.Forms.RightToLeft.Yes
Me.Label10.Size = New System.Drawing.Size(110, 28)
Me.Label10.TabIndex = 2
Me.Label10.Text = "Total Net Revenue :for Ticket Sales"
'
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label9.Location = New System.Drawing.Point(21, 59)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(95, 13)
Me.Label9.TabIndex = 1
Me.Label9.Text = "Child Ticket Sales:"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label8.Location = New System.Drawing.Point(21, 19)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(96, 13)
Me.Label8.TabIndex = 0
Me.Label8.Text = "Adult Ticket Sales:"
'
'btnCalucateTicketRev
'
Me.btnCalucateTicketRev.BackColor = System.Drawing.SystemColors.Window
Me.btnCalucateTicketRev.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnCalucateTicketRev.Location = New System.Drawing.Point(133, 315)
Me.btnCalucateTicketRev.Name = "btnCalucateTicketRev"
Me.btnCalucateTicketRev.Size = New System.Drawing.Size(96, 50)
Me.btnCalucateTicketRev.TabIndex = 4
Me.btnCalucateTicketRev.Text = "&Calculate Ticket Revenue"
Me.btnCalucateTicketRev.UseVisualStyleBackColor = False
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(235, 315)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(74, 50)
Me.btnClear.TabIndex = 5
Me.btnClear.Text = "Cl&ear"
Me.btnClear.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(316, 315)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(74, 50)
Me.btnExit.TabIndex = 6
Me.btnExit.Text = "E&xit"
Me.btnExit.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(520, 430)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.btnCalucateTicketRev)
Me.Controls.Add(Me.GroupBox4)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "Form1"
Me.Text = "Theater Revenue"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox2.PerformLayout()
Me.GroupBox3.ResumeLayout(False)
Me.GroupBox3.PerformLayout()
Me.GroupBox4.ResumeLayout(False)
Me.GroupBox4.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label10 As System.Windows.Forms.Label
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents txtAdultSold As System.Windows.Forms.TextBox
Friend WithEvents txtAdultPrice As System.Windows.Forms.TextBox
Friend WithEvents txtChildSold As System.Windows.Forms.TextBox
Friend WithEvents txtChildPrice As System.Windows.Forms.TextBox
Friend WithEvents txtTotalGross As System.Windows.Forms.TextBox
Friend WithEvents txtChildSalesGross As System.Windows.Forms.TextBox
Friend WithEvents txtAdultSalesGross As System.Windows.Forms.TextBox
Friend WithEvents txtTotalNet As System.Windows.Forms.TextBox
Friend WithEvents txtChildSalesNet As System.Windows.Forms.TextBox
Friend WithEvents txtAdultSalesNet As System.Windows.Forms.TextBox
Friend WithEvents btnCalucateTicketRev As System.Windows.Forms.Button
Friend WithEvents btnClear As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
End Class
form1.vb code:
Public Class Form1
Dim tickets_Sold_Adult As Integer
Dim ticktes_Sold_Child As Integer
Dim price_Adult As Double
Dim price_Child As Double
Dim totalAdult, totalChild, pretotal As Double
Const profitNet As Double = 0.2
Private Sub txtAdultPrice_TextChanged(sender As Object, e As EventArgs) Handles txtAdultPrice.TextChanged
If IsNumeric(txtAdultPrice.Text) Then
price_Adult = txtAdultPrice.Text
End If
End Sub
Private Sub txtAdultSold_TextChanged(sender As Object, e As EventArgs) Handles txtAdultSold.TextChanged
If IsNumeric(txtAdultSold.Text) Then
tickets_Sold_Adult = txtAdultSold.Text
End If
End Sub
Private Sub txtChildPrice_TextChanged(sender As Object, e As EventArgs) Handles txtChildPrice.TextChanged
If IsNumeric(txtChildPrice.Text) Then
price_Child = txtChildPrice.Text
End If
End Sub
Private Sub txtChildSold_TextChanged(sender As Object, e As EventArgs) Handles txtChildSold.TextChanged
If IsNumeric(txtChildSold.Text) Then
ticktes_Sold_Child = txtChildSold.Text
End If
End Sub
Private Sub btnCalucateTicketRev_Click(sender As Object, e As EventArgs) Handles btnCalucateTicketRev.Click
totalAdult = price_Adult * tickets_Sold_Adult
txtAdultSalesGross.Text = Format(totalAdult, "$0.00")
txtAdultSalesNet.Text = Format(totalAdult * 0.2, "$0.00")
totalChild = price_Child * ticktes_Sold_Child
txtChildSalesGross.Text = Format(totalChild, "$0.00")
txtChildSalesNet.Text = Format(totalChild * 0.2, "$0.00")
pretotal = (totalAdult + totalChild)
txtTotalGross.Text = Format(pretotal, "$0.00")
txtTotalNet.Text = Format(profitNet * pretotal, "$0.00")
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtAdultPrice.Clear()
txtAdultSold.Clear()
txtChildPrice.Clear()
txtChildSold.Clear()
txtAdultSalesGross.Clear()
txtAdultSalesNet.Clear()
txtChildSalesGross.Clear()
txtChildSalesNet.Clear()
txtTotalGross.Clear()
txtTotalNet.Clear()
price_Adult = 0
price_Child = 0
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
In general the best way to troubleshoot this type of problem is to get both folders (from work and from home) and diff them with a tool like WinDiff
This will give you a very clear visual difference between your projects that will teach you all kinds of things.