| | |
DataGridView integer problem?
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2007
Posts: 11
Reputation:
Solved Threads: 0
Hey people, I'm not sure what is wrong with this code and any help would be greatly appreciated:
I dont think it is passed as a value... although when I used .tostring i managed to get the interger shown.
VB.NET Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer = DGVShops.CurrentRow.Index Dim c As Integer = DGVShops.Item(0, i).Value ' gets value from selected rows first column Dim s As String = DGVShops.Item(2, i).Value ' gets a string which is the name (3rd column) ShowMe(c, s) ' passes parameters End Sub Private Sub ShowMe(ByVal c, ByVal s) Select Case c ' which should be an integer... Case 1 To 46 label.Text = (s + " some text " + c) End Select End Sub
I dont think it is passed as a value... although when I used .tostring i managed to get the interger shown.
Last edited by Fritzeh; Apr 7th, 2008 at 5:23 pm.
Where is the problem?
If the problem is with Then try using CType If the problem is the table returning a string and not an integer then this should fix it.
If the problem is with
VB.NET Syntax (Toggle Plain Text)
Dim c As Integer = DGVShops.Item(0, i).Value
VB.NET Syntax (Toggle Plain Text)
Dim c As Integer = CType(DGVShops.Item(0, i).Value, Integer)
Last edited by ptaylor965; Apr 7th, 2008 at 7:57 pm.
•
•
•
•
Hey people, I'm not sure what is wrong with this code and any help would be greatly appreciated:
[CODE]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = DGVShops.CurrentRow.Index
Dim c As Integer = DGVShops.Item(0, i).Value ' gets value from selected rows first column
Dim s As String = DGVShops.Item(2, i).Value ' gets a string which is the name (3rd column).............................................
................................
hi
i think the problem is while fetching the grid value this should be like this...
variable = datagrid1.Item(datagrid1.CurrentRowIndex, 0) ' this will give u current rows 0th column value
like wise.
check this.
Best luck.
Accept Challenges and Enjoy Coding... :)
•
•
Join Date: Apr 2007
Posts: 11
Reputation:
Solved Threads: 0
Thanks for your suggestions but I fixed the code by changing the integer to a string, I think Select Case didn't like the integer for some reason?
VB.NET Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer = DGVShops.CurrentRow.Index Dim c As Integer = DGVShops.Item(0, i).Value ' gets value from selected rows first column Dim s As String = DGVShops.Item(2, i).Value ' gets a string which is the name (3rd column) ShowMe(c, s) ' passes parameters End Sub Private Sub ShowMe(ByVal c, ByVal s) Select Case c ' which should be an integer... Case 1 To 46 label.Text = (s + " some text " + c) End Select End SubPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer = DGVShops.CurrentRow.Index Dim c As string= DGVShops.Item(0, i).Value ' gets value from selected rows first column Dim s As String = DGVShops.Item(2, i).Value ' gets a string which is the name (3rd column) ShowMe(c, s) ' passes parameters End Sub Private Sub ShowMe(ByVal c, ByVal s) Select Case c ' which should be an integer... Case 1 To 46 label.Text = (s + " some text " + c) End Select End Sub
![]() |
Similar Threads
Other Threads in the VB.NET Forum
- Previous Thread: Snapping Forms together
- Next Thread: .Net Battler Needing help Desperately lol!
| Thread Tools | Search this Thread |
"crystal .net .net2005 2008 access add advanced application array assignment basic beginner box button buttons center click code combo convert cpu cuesent data database datagrid datagridview designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall forms html image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml





