[HELP]ListBox

Posts 1–15 of 16 · Page 1 of 2
[HELP]ListBox
I am making a tutorial on how to use it for my application that im making, im using listbox.

But when i tested it, its transparent. How could i make it normal?
And if you can suggest any tool perfect for the tutorial and credits, you can post it here. /yea
Quote Originally Posted by .Celtics View Post
I am making a tutorial on how to use it for my application that im making, im using listbox.

But when i tested it, its transparent. How could i make it normal?
And if you can suggest any tool perfect for the tutorial and credits, you can post it here. /yea
Um, how's the listbox being presented? Is there any relevant code you should show us? And by transparent...do you mean you can't see the ListBox at all or what?

Need moar inf0!
Oh wait, fixed the transparent thingy.

But can you suggest anything used for credits and such?
Can find a good tool, just listbox

and offtopic question,
how can you check if the user of the application has internet connection?
Thanks ;p
Quote Originally Posted by .Celtics View Post
Oh wait, fixed the transparent thingy.

But can you suggest anything used for credits and such?
Can find a good tool, just listbox

and offtopic question,
how can you check if the user of the application has internet connection?
Thanks ;p
Ping Google, which has a 100% uptime rate.
There are a few ways, but the best way is to try and resolve a Domain Name:


Imports System.Net

Now create a function

Code:
 Public Function CheckCon(ByRef url As String) As Boolean
        Dim URI As New System.Uri(url)
        Dim Check As WebRequest = WebRequest.Create(URI)
        Dim Answer As WebResponse
        Try
            Answer = Check.GetResponse()
            Answer.Close()
            Answer = Nothing

            Answer.Close()
            Check = Nothing

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function
We will use this function to check for a connection using

Code:
 If CheckCon("http://google.com") = False Then
            MsgBox("You Have a connection")
        Else
            MsgBox("Sorry no connection available")

        End If
Hope this helps.
Quote Originally Posted by NextGen1 View Post
There are a few ways, but the best way is to try and resolve a Domain Name:


Imports System.Net

Now create a function

Code:
 Public Function CheckCon(ByRef url As String) As Boolean
        Dim URI As New System.Uri(url)
        Dim Check As WebRequest = WebRequest.Create(URI)
        Dim Answer As WebResponse
        Try
            Answer = Check.GetResponse()
            Answer.Close()
            Answer = Nothing

            Answer.Close()
            Check = Nothing

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function
We will use this function to check for a connection using

Code:
 If CheckCon("http://google.com") = False Then
            MsgBox("You Have a connection")
        Else
            MsgBox("Sorry no connection available")

        End If
Hope this helps.
You just did what could be done in 5 lines in 30 lines /:

I'd write up an example for you, but I'm on my mobile now.
There's an eaiser way to check for network connection status, which is entirely different, but I stand by my function as the most practical way to check for a internet connection, and possibly the most accurate.

So :waits: for better example




The most efficient way will be using built-in DNS class:

Dim site As IPHostEntry
site = Dns.Resolve(Google)

If site's members returns proper values, then the site is reachable else not !! (On university pc, can't test it, but should work) !
Code:
Try
	System.Net.IPHostEntry = System.Net.Dns.GetHostByName("www.google.com")
	Return True
Catch
			Return False
End Try
You could also do

Code:
 
    Private Function Conn() As Boolean
        Try
            Dim check As New System.Net.Sockets.TcpClient("www.google.com", 80)
           check.Close()
            Return True
        Catch
            Return False
        End Try
    End Function
However, there are slight issues with all of the above.
I still stand by my method as being the better solution.

But it's up to the OP in all cases.

This is probably solved.
Quote Originally Posted by NextGen1 View Post
Code:
Try
	System.Net.IPHostEntry = System.Net.Dns.GetHostByName("www.google.com")
	Return True
Catch
			Return False
End Try
You could also do

Code:
 
    Private Function Conn() As Boolean
        Try
            Dim check As New System.Net.Sockets.TcpClient("www.google.com", 80)
           check.Close()
            Return True
        Catch
            Return False
        End Try
    End Function
However, there are slight issues with all of the above.
I still stand by my method as being the better solution.

But it's up to the OP in all cases.

This is probably solved.
Code:
If My.Computer.Network.Ping("google.com") Then
  MsgBox("Online.")
Else
  MsgBox("Offline.")
End If
This code does not raise any exceptions, as far as i know.
Quote Originally Posted by freedompeace View Post
Code:
If My.Computer.Network.Ping("google.com") Then
  MsgBox("Online.")
Else
  MsgBox("Offline.")
End If
This code does not raise any exceptions, as far as i know.
True, and thought of that already but I thought DNS is more efficient, but this will work great too !!
Quote Originally Posted by Hassan View Post


True, and thought of that already but I thought DNS is more efficient, but this will work great too !!
The DNS resolution isn't as accurate - the DNS host entry may be cached (not sure if .NET uses cache for this), may be blocked by a corporate firewall, antivirus software or proxy, and thus redirected elsewhere, such as the company's intranet (when access to the Internet may not be available) or nowhere at all, or have the domain redirected using the hosts DNS file.

In these respects, pinging the server would be better O:
But if you ping and the site is offline.
You get a message that internet is unavailble. Which is inaccurate..
we have to keep in mind many users.

Firewall limitations, same thing.

sometimes you have to sacrifice blank space for effective code.

Code:
 <DllImport("wininet.dll")> _
    Private Shared Function InternetGetConnectedState(<System.Runtime.InteropServices.Out()> ByRef Description As Integer, ByVal ReservedValue As Integer) As Boolean
    End Function
    
        Dim description As Integer
        If InternetGetConnectedState(description, 0) = True Then
            MessageBox.Show("Network connected")
        Else
            MessageBox.Show("No network connection found")
        End If
either case, the best is which one works for the user.
Quote Originally Posted by NextGen1 View Post
But if you ping and the site is offline.
You get a message that internet is unavailble. Which is inaccurate..
we have to keep in mind many users.

Firewall limitations, same thing.

sometimes you have to sacrifice blank space for effective code.

Code:
 <DllImport("wininet.dll")> _
    Private Shared Function InternetGetConnectedState(<System.Runtime.InteropServices.Out()> ByRef Description As Integer, ByVal ReservedValue As Integer) As Boolean
    End Function
    
        Dim description As Integer
        If InternetGetConnectedState(description, 0) = True Then
            MessageBox.Show("Network connected")
        Else
            MessageBox.Show("No network connection found")
        End If
either case, the best is which one works for the user.
May I remind you that Google has a 100% uptime rate. And so does Microsoft. As does Apple. I wonder what happens if we pinged one after the other one (on the condition that the previous one failed). Which is more accurate now?

I lead people in the right direction. It is up to the individual to use their brain to further extend this code.
Quote Originally Posted by freedompeace View Post
May I remind you that Google has a 100% uptime rate. And so does Microsoft. As does Apple. I wonder what happens if we pinged one after the other one (on the condition that the previous one failed). Which is more accurate now?

I lead people in the right direction. It is up to the individual to use their brain to further extend this code.
NVM ............
Posts 1–15 of 16 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?