Results 1 to 9 of 9

Thread: Convert Error from VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Convert Error from VB6

    I have converted my old project from VB6 to VB2008 but there is an uggly error that I chould not resolve.
    It whould be great if some one can help me . My error shows this line :

    Code:
    DebugXML.Text = Inet1.OpenURL("http://
    it can not accept this argument ?

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Convert Error from VB6

    Quote Originally Posted by deve View Post
    I have converted my old project from VB6 to VB2008 but there is an uggly error that I chould not resolve.
    It whould be great if some one can help me . My error shows this line :

    Code:
    DebugXML.Text = Inet1.OpenURL("http://
    it can not accept this argument ?
    I don't suppose VB6 would either if that line is complete! Assuming it does end logically and that DebugXML.Text is a textbox(?), what is Inet1 and what are you actually wanting this to do?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: Convert Error from VB6

    this is all of the code :

    Code:
    DebugXML.Text = Inet1.OpenURL("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/" & Text2.Text & "/cars")
    			xml_document.loadXML(DebugXML.Text)
    			xm1_node = xml_document.getElementsByTagName("worldCar")
    			xm2_node = xml_document.getElementsByTagName("physicsProfile")
    			DebugXML.Text = CStr(CDbl(xm1_node(0).Text) + xm2_node(0).Text)

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Convert Error from VB6

    Well that makes it a bit clearer. No, VB.Net doesn't handle XML files in that way. There are actually a number of different ways to approach XML. The following, which exploits .Net's inbuilt LINQ support, may be instructive. If not, there are many references on the net. Stick to the most recent!

    vb.net Code:
    1. Dim doc As XDocument
    2.         doc = XDocument.Load("http://dl.dropbox.com/u/8842115/sample.xml")
    3.         For Each node In doc.Descendants("first")
    4.             DebugXML.AppendText((CType(node.Element("name"), String)) & vbCrLf)
    5.         Next

    xml Code:
    1. <root>
    2. <first>
    3. <no>10</no>
    4. <name>mr. a</name>
    5. </first>
    6. <first>
    7. <no>20</no>
    8. <name>mr. b</name>
    9. </first>
    10. </root>
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: Convert Error from VB6

    I am not getting it correctly sorry , how whould I go with this xml output if I wont to have the nodes : carID - make - carName - acceleration - handling - rating - topspeed - carclass ?

    <worldCar carId="14717367" make="CAR_MANU_MITSUBISHI" carName="CAR_MDL_ECLIPSEGT">
    <physicsProfile acceleration="219" handling="300" rating="254" topSpeed="243" carClass="carclass_d"/>
    </worldCar>-

    P.S I start to use VS 2010
    Last edited by deve; Sep 9th, 2012 at 02:56 PM.

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Convert Error from VB6

    One way ... you can tidy it up once you've seen how it works ...

    vb.net Code:
    1. For Each node In doc.Descendants("worldCar")
    2.             Dim ss As String() = Split(node.ToString, " ")
    3.             For i = 0 To ss.Length - 1
    4.                 DebugXML.AppendText(i.ToString & " " & ss(i) & vbCrLf)
    5.             Next
    6.         Next
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: Convert Error from VB6

    ok my result code looks like this :

    Code:
          Dim doc As XDocument
                doc = XDocument.Load("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/nfswdriver/car")
                For Each node In doc.Descendants("worldCar")
                    Dim ss As String() = Split(node.ToString, " ")
                    For i = 0 To ss.Length - 1
                        TextBox2.Text = (i.ToString & " " & ss(i) & vbCrLf)
                    Next
                Next
    result that I get is this only :
    12 />
    </worldCar>
    Last edited by deve; Sep 9th, 2012 at 04:02 PM.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: Convert Error from VB6

    Final code looks like this :

    Code:
      Dim doc As XDocument
                doc = XDocument.Load("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/" + TextBox1.Text + "/car")
                For Each node In doc.Descendants("worldCar")
                    Dim ss As String() = Split(node.ToString, "carId")
                    For i = 0 To ss.Length - 1
                        TextBox2.Text = " Drivers Name : " + TextBox1.Text + vbCrLf + (i.ToString & " " & ss(i) & vbCrLf)
                    Next
                Next
    output looks like this :

    PHP Code:
    Drivers Name nfswdev
    ="13512645" make="CAR_MANU_DODGE" carName="CAR_MDL_CHARGER07BEE">
      <
    physicsProfile acceleration="547" handling="247" rating="406" topSpeed="426" carClass="carclass_c" />
    </
    worldCar
    What is the 1 in the beginning ? and how can I put all the nodes 1 by 1 in line. like
    car id : result
    acceleration : result
    and so on


    the real XML output on the webpage is like this :

    PHP Code:
    <worldCar carId="13512645" make="CAR_MANU_DODGE" carName="CAR_MDL_CHARGER07BEE">
    <
    physicsProfile acceleration="547" handling="247" rating="406" topSpeed="426" carClass="carclass_c"/>
    </
    worldCar

  9. #9
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Convert Error from VB6

    Er ... yes ... slight difference between ....

    DebugXML.AppendText(i.ToString & " " & ss(i) & vbCrLf)

    and

    TextBox2.Text = (i.ToString & " " & ss(i) & vbCrLf)
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

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