Solved

I have a problem I want to convert vb code to c# code

Posted on 2007-11-15
2
291 Views
Last Modified: 2012-05-05
Function URLDecode(What)
         Dim Pos, pPos
       What = Replace(What, "+", " ")
         On Error Resume Next
         Dim Stream: Set Stream = CreateObject("ADODB.Stream")
         If Err = 0 Then 'URLDecode using ADODB.Stream, If possible
           On Error GoTo 0
           Stream.Type = 2 'String
           Stream.Open
           Pos = InStr(1, What, "%")
           pPos = 1
           Do While Pos > 0
             Stream.WriteText Mid(What, pPos, Pos - pPos) + _
               Chr(CLng("&H" & Mid(What, Pos + 1, 2)))
             pPos = Pos + 3
             Pos = InStr(pPos, What, "%")
           Loop
           Stream.WriteText Mid(What, pPos)
           Stream.Position = 0
           URLDecode = Stream.ReadText
           Stream.Close
         Else
           On Error GoTo 0
           Pos = InStr(1, What, "%")
           Do While Pos > 0
              What = Left(What, Pos - 1) + _
               Chr(CLng("&H" & Mid(What, Pos + 1, 2))) + _
               Mid(What, Pos + 3)
             Pos = InStr(Pos + 1, What, "%")
           Loop
           URLDecode = What
         End If
         Set Stream = Nothing
        End Function
       
0
Comment
Question by:sitg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
webressurs earned 500 total points
ID: 20298168
I guess there is some errors in your code...
Try this when converting from c# -> vb.net / vb.net -> c#:
http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx
0
 

Author Comment

by:sitg
ID: 20310378
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question