Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Reader String


Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2012, 11:13 AM
JackPS9 JackPS9 is offline
Newcomer
 
Join Date: Jun 2012
Posts: 11
Default Reader String


How can I convert the item number in the combo box to be use able?
I keep getting told to change RaceNum to a double but I need the RaceNum to stay as a int so it reads the files 1-15 but it starts at 0.

Error that I keep getting.
"Conversion from string "C:\Users\Home\Pictures\Tim\Tides" to type 'Double' is not valid."

I can't continue on coding till it works cause its part of how a player sets up their character for my game.

Code:
    Private Sub cboRace_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboRace.SelectedIndexChanged
        RaceNum = cboRace.SelectedItem
        Race = CurDir() + "/Plugins/Races/Race"
        Race = Race + RaceNum
        Race = Race + ".phg"
        Dim Reader As New System.IO.StreamReader(Race)

Last edited by JackPS9; 06-29-2012 at 11:56 AM.
Reply With Quote
  #2  
Old 06-29-2012, 03:56 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,678
Default

Where is RaceNum declared?

The error isn't the fact that RaceNum is an int or a double the problem is the selected item is a string such as "C:\Users\Home\Pictures\Tim\Tides" and this can't be converted to a numeric type.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 06-30-2012, 12:41 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 5,882
Default

What you are looking for is not selecteditem (The content), but selectedindex (The Item Offset number from zero). To return a number from 1 you will have to add 1.

Code:
Private Sub cboRace_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboRace.SelectedIndexChanged RaceNum = cboRace.SelectedIndex + 1 '<-- index Not Item Race = CurDir() + "/Plugins/Races/Race" Race = Race + RaceNum Race = Race + ".phg" Dim Reader As New System.IO.StreamReader(Race) ...
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->