Wednesday, 28 December 2016
Sunday, 4 December 2016
How to calculate all value of datagridview column in single code
Dim sumcolumn As Integer = (From row As DataGridViewRow In DataGridView1.Rows Where row.Cells(0).FormattedValue.ToString() <> String.Empty Select Convert.ToInt32(row.Cells(0).FormattedValue)).Sum().ToString()
Wednesday, 20 July 2016
Combobox Display member and Value Member
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim key As String = DirectCast(ComboBox1.SelectedItem, KeyValuePair(Of String, String)).Key
Dim value As String = DirectCast(ComboBox1.SelectedItem, KeyValuePair(Of String, String)).Value
MessageBox.Show(key & " " & value)
End Sub
'' Add items to combobox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim comboSource As New Dictionary(Of String, String)()
comboSource.Add("25 Year", "Nishant")
comboSource.Add("26 Year", "Ravi")
comboSource.Add("27 Year", "Mohan")
ComboBox1.DataSource = New BindingSource(comboSource, Nothing)
ComboBox1.DisplayMember = "Value"
ComboBox1.ValueMember = "Key"
End Sub
Wednesday, 20 April 2016
Armstrong number in vb.net
Dim x As String
Dim y As Integer
For index As Integer = 0 To 10000
x = ""
y = 0
Dim x1 As Integer = index
Dim s As String = x1.ToString
Dim a(s.Length) As String
For i As Integer = s.Length - 1 To 0 Step -1
x = s.Substring(i, 1) & x
y = y + (s.Substring(i, 1) * s.Substring(i, 1) * s.Substring(i, 1))
Next
If Val(x) = y Then
Label1.Text = Label1.Text & vbCrLf & x
End If
Application.DoEvents()
Next
Subscribe to:
Posts (Atom)