EvilZone
Programming and Scripting => .NET Framework => : iAmLuFFy October 26, 2011, 07:45:45 PM
-
While i am learning VB.NET
i tried to design one simple form with one simple database
in Visual studio 2010 ultimate and Access 2010 database
here is code Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.LoadMe.HostelTableAdapter.Fill(Me.DataentryDataSet.Hostel)
TextBox1.ReadOnly = True
TextBox2.ReadOnly = True
TextBox3.ReadOnly = True
TextBox4.ReadOnly = True
TextBox5.ReadOnly = True
TextBox6.ReadOnly = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click
Me.HostelBindingSource.MoveFirst()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button2.Click
Me.HostelBindingSource.MovePrevious()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button3.Click
Me.HostelBindingSource.MoveNext()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button4.Click
Me.HostelBindingSource.MoveLast()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button6.Click
Me.HostelBindingSource.RemoveCurrent()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button5.Click
Me.HostelBindingSource.AddNew()
TextBox1.ReadOnly = False
TextBox2.ReadOnly = False
TextBox3.ReadOnly = False
TextBox4.ReadOnly = False
TextBox5.ReadOnly = False
TextBox6.ReadOnly = False
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button8.Click
TextBox1.ReadOnly = False
TextBox2.ReadOnly = False
TextBox3.ReadOnly = False
TextBox4.ReadOnly = False
TextBox5.ReadOnly = False
TextBox6.ReadOnly = False
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button7.Click
Me.Validate()
Me.HostelBindingSource.EndEdit()
Me.HostelTableAdapter.Update(Me.DataentryDataSet)
TextBox1.ReadOnly = True
TextBox2.ReadOnly = True
TextBox3.ReadOnly = True
TextBox4.ReadOnly = True
TextBox5.ReadOnly = True
TextBox6.ReadOnly = True
End Sub
End Class
and here is image of that form
(http://i44.tinypic.com/fep2mt.png)
i have atteched project here
-
wait a few minutes, you sir learning vb.net? while you could learn php?
-
wait a few minutes, you sir learning vb.net? while you could learn php?
Actully
i am learning php by my self.... but i have a guide(i mean coching class) for VB.NET.. so VB.NET is regular 2 hour classes since 10 days....
but i am learning PHP slowly side by side...
and that form is about 4 days old... just posting it now...
-
Tips:
1. Name your controls. When you're looking at your code Button6 means nothing. The best standard is to prefix the name with an abbreviated control type. i.e. button becomes btn, then follow with what the button is used for. btnSave, btnOK, btnClose, etc. The same for your text boxes, you currently don't know what value is stored in TextBox4 for example without going and checking what label it is next to. txtFees would be much more suitable.
2. If you frequently need to change the state of a group of controls like the ReadOnly state. Put it into a function. It saves you having to write the code out several times, makes your program smaller and more efficient, and also means that if you need to change the code, you only have to do it in one place. e.g.
Private Sub flipTextBoxReadOnly()
TextBox1.ReadOnly = !TextBox1.ReadOnly
TextBox2.ReadOnly = !TextBox2.ReadOnly
TextBox3.ReadOnly = !TextBox3.ReadOnly
TextBox4.ReadOnly = !TextBox4.ReadOnly
TextBox5.ReadOnly = !TextBox5.ReadOnly
TextBox6.ReadOnly = !TextBox6.ReadOnly
End Sub
3. VB is shit, haha.
-
ok.. i got it... thank you buddy..