Author Topic: Just a Starting with VB.NET  (Read 1569 times)

0 Members and 1 Guest are viewing this topic.

Offline iAmLuFFy

  • Knight
  • **
  • Posts: 226
  • Cookies: 6
  • i aM MoDiFiEr nOt A cReAtOr
    • View Profile
Just a Starting with VB.NET
« on: 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
Code: [Select]
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
 

 
 
i have atteched project here
 
 
iAmLuFFy

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: Just a Starting with VB.NET
« Reply #1 on: October 26, 2011, 08:29:39 pm »
wait a few minutes, you sir learning vb.net? while you could learn php?
~Factionwars

Offline iAmLuFFy

  • Knight
  • **
  • Posts: 226
  • Cookies: 6
  • i aM MoDiFiEr nOt A cReAtOr
    • View Profile
Re: Just a Starting with VB.NET
« Reply #2 on: October 26, 2011, 09:54:39 pm »
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...
 
iAmLuFFy

xor

  • Guest
Re: Just a Starting with VB.NET
« Reply #3 on: October 28, 2011, 11:01:12 am »
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.

Code: [Select]
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.

Offline iAmLuFFy

  • Knight
  • **
  • Posts: 226
  • Cookies: 6
  • i aM MoDiFiEr nOt A cReAtOr
    • View Profile
Re: Just a Starting with VB.NET
« Reply #4 on: October 28, 2011, 03:23:17 pm »
ok.. i got it... thank you buddy..
iAmLuFFy