Results 1 to 4 of 4

Thread: VB.NET: Option Strict ON conversion....[Resolved]

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    VB.NET: Option Strict ON conversion....[Resolved]

    I heard that working on codes with Option Strict ON give me a better way to learn programming....
    Say I have turn the Option Strict ON....
    all the coding works well when the option Strict is OFF.....

    1) How to convert the error "String to Integer" in this case
    Code:
    Dim data As String
    For Each nod As XmlNode In xdoc.SelectNodes("//time")
        data = nod.Attributes("hour").Value
        cboVHour.SelectedIndex = data
    Next
    2) Secondly, I have this String which take in Integer, how to solve the error "Integer to String" in the second case.
    Code:
    Dim dd As Integer
    dd = Now.Day
    lblDay.Text = dd
    3) Lastly, I have an Xml String and I wanted to display an additional day to it in the Xml String. How to solve thr error "String to Double" in this third case.
    Code:
     XmlString = "<OK>" &  dd + 1 & "</OK>"
    Thanks
    Last edited by toytoy; Dec 3rd, 2004 at 07:50 AM.

  2. #2
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296
    Hi,

    I'm no master programmer yet, and don't have vb.net on the machine I'm on now.

    Just wanted to say, Don't give up on using Option Strict On. Forces you to figure out the "right" way of doing things.

    From the top of my head:
    1) Play around with adding .ToString (like nod.Attributes("hour").Value.ToString
    2) Pllay around with CType and DirectCast

    Good Luck

  3. #3
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    The Convert class allows you to do most of what you want to do.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  4. #4

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    I solve it...

    For the First one:
    Code:
    Dim data As String
    For Each nod As XmlNode In xdoc.SelectNodes("//time") 
        data = nod.Attributes("hour").Value 
        cboVHour.SelectedIndex = CInt (data) 
    Next 
    'OR
    Dim data As String
    For Each nod As XmlNode In xdoc.SelectNodes("//time") 
        data = nod.Attributes("hour").Value 
        cboVHour.SelectedIndex = Integer.Parse (data) 
    Next
    For the Second one:
    Code:
    Dim dd As Integer 
    dd = Now.Day 
    lblDay.Text = CStr(dd) 
    'OR
    Dim dd As Integer 
    dd = Now.Day 
    lblDay.Text = dd.ToString


    The last one is my error.....It could works well

    Could anyone sent me any link or suggestion that i might face during the changes made from the Option Strict set to ON...

    Thanks in advance
    Last edited by toytoy; Dec 3rd, 2004 at 07:50 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width