| | |
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 |
.net .net2008 2008 access account add advanced application array basic beginner browser button buttons click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview mobile module monitor mysql net number objects open panel pdf picturebox picturebox2 port position print printing printpreview problem regex reuse right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vba vbnet vista visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





