Hi,
Newbie programmer here. I have a small invoicing application I'm trying to build, but I'm stuck.
There are multiple textboxes that need to be enabled/ disabled in groups through checkboxes, based on how many techs are on the job.
For example, each tech will have separate expenses (airfare, hotel, car, gas, etc.) as well as different working hours (separated into regular, overtime, travel, weekend, etc.).
The idea is to have the first column (tech1) enabled by default, and everything else disabled on load. Then based on checkboxes enable the column for each additional tech.
Each tech has about 20 fields to be enabled/disabled, which means a LOT of code if I need to write a line of code to enable/disable each box. I'm sure there has to be an "easy" way to do this with much less code. But as my opening says, I'm a newbie.
Here is an example of the way I found to do this.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
CheckBox2.Enabled = False
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox3.Enabled = True
TextBox4.Enabled = True
CheckBox2.Enabled = True
Else
TextBox3.Enabled = False
TextBox4.Enabled = False
CheckBox2.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
End If
If CheckBox1.Checked And CheckBox2.Checked = True Then
TextBox5.Enabled = True
TextBox6.Enabled = True
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox5.Enabled = True
TextBox6.Enabled = True
Else
TextBox5.Enabled = False
TextBox6.Enabled = False
End If
End Sub
End Class