| | |
DataGridView integer problem?
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
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 .net2008 30minutes 2008 access add application array assignment basic beginner box browser button buttons click code combo connectionstring convert cpu cuesent data database databasesearch datagrid datagridview datetimepicker design designer dissertation dissertations dissertationthesis dissertationtopic dosconsolevb.net editvb.net exists firewall folder forms html image images isnumericfuntioncall listview math mobile module mssqlbackend mysql navigate number opacity open panel peertopeervideostreaming picturebox2 port print printing printpreview record regex reports" reuse right-to-left savedialog serial settings socket sqldatbase sqlserver storedprocedure string temp textbox timer timespan transparency txttoxmlconverter useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml year





