Public Class Form1
Public Const cFmtCurrency As String = "##,###,###" ' don't need decimal for the local China currency
Private Sub setCoolHandlersForTextBoxes()
For Each myCoolTextBox In New TextBox() {TextBox1, TextBox2, TextBox3}
AddHandler myCoolTextBox.Validated, AddressOf _myCoolTextBoxes_Validated '// set the event to be handled by each TextBox.
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
setCoolHandlersForTextBoxes()
End Sub
Private Sub _myCoolTextBoxes_Validated(ByVal sender As Object, ByVal e As System.EventArgs)
With CType(sender, TextBox)
If Not .Text = "" AndAlso IsNumeric(.Text) Then .Text = CInt(.Text).ToString(cFmtCurrency) '// Format.
End With
End Sub
End Class
Public Class Form1
Private WithEvents tmrMain As New Timer With {.Interval = 2000, .Enabled = True}
Private rnd As New Random
Private Sub tmrMain_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrMain.Tick
Static r, g, b As Integer
r = rnd.Next(0, 256) : g = rnd.Next(0, 256) : b = rnd.Next(0, 256)
Me.BackColor = Color.FromArgb(r, g, b)
End Sub
End Class
Not a math.wiz, just hobbyist programmer, and am just wondering; How are the calculations added up to return those results?
.ex: "C=0.4857143", though how are you getting that value?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
Static btnName As String = "" '// stores .Name of btn.
With CType(sender, Button)
If btnName = "" Then MsgBox(.Name) Else MsgBox("previous btn: " & btnName)
btnName = .Name '// add value to your string "AFTER".
End With
End Sub
.line.14, include those values in parentheses: "Total pay: " & (txtHoursWorked.Text * lstHourlyRate.SelectedItem + txtHoursOvertime.Text * DoubleRate)) and it should work.
This is the LinkLabel.Form and Form1 is your login.Form.
Public Class Form2
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Me.Hide()
With Form1
.TextBox1.Clear() : .TextBox2.Clear() '// un/pw TextBoxes.
.ShowDialog()
End With
Me.Close()
End Sub
End Class
>>yes it want support on this
See if this helps.:)
Imports System.IO
Public Class Form1
Private myFile As String = "c:\test.txt"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.AddRange(New String() {"1", "f1", "f2"})
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Static selCoolItem As String '// stores the .SelectedItem to verify against the previously .SelectedItem.
With ListBox1
If Not .SelectedIndex = -1 Then '// if itm selected.
If Not selCoolItem = .SelectedItem Then '// check if same item as previously .SelectedItem, if one selected.
selCoolItem = .SelectedItem '// store .SelectedItem in String.
For Each itm As String In File.ReadAllLines(myFile) '// read File.Lines and...
If itm = selCoolItem Then Return '// ...Exit Sub w/less typing. ;)
Next
Dim w As New IO.StreamWriter(myFile, True) : w.WriteLine(selCoolItem) : w.Close() '// append to File.
End If
End If
End With
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.AddRange(New String() {"1", "f1", "f2"})
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Static selCoolItem As String '// stores the .SelectedItem to verify against the previously .SelectedItem.
With ListBox1
If Not .SelectedIndex = -1 Then '// if itm selected.
If Not selCoolItem = .SelectedItem Then '// check if same item as previously .SelectedItem, if one selected.
selCoolItem = .SelectedItem '// store .SelectedItem in String.
Dim w As New IO.StreamWriter("c:\test.txt", True) : w.WriteLine(selCoolItem) : w.Close() '// append to File.
End If
End If
End With
End Sub
End Class
If you don't want the same item to be added to the file, load File in an Array, loop thru all lines and if item found Then Exit the entire Sub with "Exit Sub". If not found, have the code to append to file just underneath your For/Next loop.
Public Class Form1
Private WithEvents tmr As New Timer With {.Enabled = True} '// dynamic.Timer.
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
Me.Text = ListBox1.TopIndex '// display the top visible item's Index.
End Sub
End Class
Just wondering; do the lines have to be in the Button's.Click event or can they be in separate Subs?as:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
someCoolSub()
someOtherCoolSub()
End Sub
Private Sub someCoolSub()
MsgBox("someCoolSub")
End Sub
Private Sub someOtherCoolSub()
MsgBox("someOtherCoolSub")
End Sub
Reason I'm asking is because you can use the Threading.Thread.Sleep , although that will freeze your entire application for 5 seconds, not just pause the the time between running the rest of the lines of code.
With DataGridView1
Static iTopRow As Integer
iTopRow = .FirstDisplayedScrollingRowIndex '// get Top row.
Form2.ShowDialog()'// Form that edits record.
.FirstDisplayedScrollingRowIndex = iTopRow '// set Top row.
End With
For i As Integer = 0 To picBoxes.Length - 1
With picBoxes(i)
.pictureBox = CType(Me.Controls("PictureBox" & i + 1), PictureBox)
.cover = My.Resources.ImperialLogo
.pictureBox.Image = .cover
End With
Next
edit::
To make it easier on you the next time you need to add more than one control to an event, use something as this in Form_Load, instead of adding "pic1.click, pic2.click, picEtc.click".
For i As Integer = 1 To 36
With CType(Me.Controls("PictureBox" & i), PictureBox)
AddHandler .Click, AddressOf PictureBox1_Click
End With
Next
>>Not 100% sure what you mean by 2 ArrayLists.
Simple.
Public Class Form1
Private arlFullNames, arlUserNames As New ArrayList
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
arlFullNames.Add("some full name")
arlUserNames.Add("some full name's username")
arlFullNames.Add("another full name")
arlUserNames.Add("another full name's username")
ComboBox1.Items.AddRange(arlFullNames.ToArray)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
MsgBox(arlUserNames(ComboBox1.SelectedIndex))
End Sub
End Class
Not a database coder here, though could you not remove InvNomer, from sSql = "SELECT FullName ,InvNomer, BalanceDue From Invoice" and have it as sSql = "SELECT FullName , BalanceDue From Invoice" ?
>>I don't think your code (Above) will prevent this from happening, what's the best way to tackle that?
Entirely different question and I only replied to this thread for this question.
>>(PS. I'm a really new to coding,...
Would have never guessed.:D
As for the rest, glad I could help:); and If issue solved, then the thread should be as well.
Something else before I delete your project from my.p.c..
.I would place those images on frmHomePage in a Button's.BackgroundImage; just makes nice eye candy for the user when you hover over the btn.:)(view.attached)