Click here to Skip to main content
15,891,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Option Strict Off
Option Explicit On
Module Module1
	Dim winhttp As New WinHttp.WinHttpRequest
	Public Function Version() As Boolean
		Dim WebVer As Object
		On Error Resume Next
        winhttp.Open("GET", "http://www.********.com/upd/webver.txt")
		winhttp.Send()
        WebVer = StrConv(winhttp.ResponseBody, vbUnicode)
		Form1.WebVer.Text = WebVer
	End Function
	Public Function Version2() As Boolean
		Dim ClientVer As Object
		On Error Resume Next
        winhttp.Open("GET", "http://www.********.com/upd/clientver.txt")
		winhttp.Send()
        ClientVer = StrConv(winhttp.ResponseBody, vbUnicode)
		Form1.ClientVer.Text = ClientVer
	End Function
End Module


And it gives me 2 errors.

Error 1 Name 'vbUnicode' is not declared.C:\Users\Juss\Desktop\Project1.NET\Module1.vb 10 48 Project1
Error 2 Name 'vbUnicode' is not declared. C:\Users\Juss\Desktop\Project1.NET\Module1.vb 18 51 Project1

I'm really new in this, and all the help would be really appriciated!
Posted
Updated 1-Jun-15 14:55pm
v2
Comments
[no name] 1-Jun-15 21:22pm    
https://msdn.microsoft.com/en-us/library/aa263373(v=vs.60).aspx
Sergey Alexandrovich Kryukov 1-Jun-15 22:13pm    
What do you mean by "VB" here?
—SA
F. Xaver 2-Jun-15 2:37am    
looks like .Net .. but.. Set 'Option Strict ON'
and get rid of 'On Error Resume Next' .. thats VB6 Error handling. there are nicer things in .net ^^

You don't need the WinHttp reference - the .NET framework has plenty of built-in classes to do this for you. For example, the DownloadString method[^] from the System.Net.WebClient class[^]:
VB
Option Strict On
Option Explicit On

Imports System.Net

Module Module1
    Public Function Version() As Boolean
        Dim wc As New WebClient()
        Dim WebVer As String = wc.DownloadString("http://www.********.com/upd/webver.txt")
        Form1.WebVer.Text = WebVer
        
        Return True ' Functions need to return a value.
    End Function

    Public Function Version2() As Boolean
        Dim wc As New WebClient()
        Dim ClientVer As String = wc.DownloadString("http://www.********.com/upd/clientver.txt")
        Form1.ClientVer.Text = ClientVer
        
        Return True ' Functions need to return a value.
    End Function
End Module
 
Share this answer
 
Comments
Maciej Los 2-Jun-15 15:00pm    
Tag is VB, not VB.net ;)
Richard Deeming 2-Jun-15 15:05pm    
But the question is VB.NET. :)

(Option Strict didn't exist in VB6.)
Maciej Los 2-Jun-15 15:08pm    
I haven't seen Option Strict earlier... Yeah, you're right, it seems to be VB.NET.
+5!
vbUnicode is one of built-in constans. A reference to VBE7.dll is needed.

For further information, please see: Visual Basic for Applications Reference: StrConv function[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900