I think you want the ASP.NET or WPF forums. It doesn't sound like this has anything to do with VB.NET.
I think you mean that when the user presses F1 in their browser (while running your app), you want a help file for your app to come up instead of the help for the browser. AFAIK, you cannot change that behavior.
I am working on a WPF application with .Net Framwork 3.5. On my application Window I have a free text box. Is there any class in .Net which helps in determining the datatype of the typed text in the text box?
If user types "Vipul1234" OR "Vipul" then the class should determine the data typed in the textbox is of type String
If user types "1234" then the class should determine the data typed in the textbox is of type int
what you type in a TextBox is text, hence a string.
it may also represent something else, such as an int, a double, a DateTime, etc.
In order to check, you should call TryParse on each relevant type, and be careful about the order
(so an integer may turn into either an int or a double).
Well, TryParse, whatever the base class, will try and parse the string; it will fail when the
data does not fit the type you are trying to parse, so a sequence of different TryParse calls
should be sufficient to determine the type. Check the documentation on int32.TryParse, DateTime.TryParse
Wouldn't it make more sense to use the textbox as it was intended to be used - to capture text - then cast the input to whatever type you need? Even if you're re-using a control for different types, your application should "know" what it's expecting at each point. If that isn't the case, you can try casting the input to various types and catching the exceptions thrown to determine the type. Even so, you're going to get misleading results if, for example, you ask for a password and the user chooses '123456' as a password. Better, I think, to clearly define what you expect at each input opportunity and constrain the input to compatible types.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
I want to know how the above mentioned can be done using TCP/IP where i can maintain number of clients connected and when the client gets disconnected so that I can check whether to allow any more clients to connect.
From what i have understood , by reading your question is that you need to maintain number of clients connected to a server , right ?
But you are using UDP Protocol , which is connection less protocol , i think it is not a wise choice to use UDP , if you need to keep record of the connections you should TCP protocol.
The following link can help you use TCP protocol for communication
just let me know if TCP suits your requirement , we can move ahead , with the actual question , we can maintain the count if we use TCP , i am not sure how to do it by using UDP , The logic say we cannot do it , as it is a connection less protocol
The only idea that come to my mind is
we will maintain of connect client (in a list object) , when ever a client tries to connect we will call a function (implementation on the function is as given below ), which will a loop through the list and use the connected property to find if the client is still connected , the implementation of the function goes like this
Private Function NumberOfClientConnected() As Integer
Dim tempclient As TcpClient
Dim totalClientConnected As Integer
totalClientConnected = 0
For Each tempclient In connectedClients
If tempclient.Connected Then
totalClientConnected = totalClientConnected + 1
for this you have to declare a Module level variable of type list , remember its a module level variable.
Dim connectedClients As New List(Of TcpClient)
Also there is a small change in the previous code after
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
we need to add the following line
Also before Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
We need to add a if condition
If NumberOfClientConnected() > <maxclientallowe> then
So the summary is
1) We maintain a list to TCPClient Connected
2) Then we loop through the list and check for still connected client by using the Connected property
3) If the server has not reached the maximum number of client connected , we accept the connection and add it to the list..
I hope it is helpful , i am sorry if there are any build error , i have not tried it in the IDE , i dont have one installed right now , i am i hurry right now , need to go .........
Thanks very Much for your Valuable Response and time.
The above code was what something i was looking for, Thank you very much.
I have tried the code in a small application and the problem i am facing now is as below,
I can Connect to the Server and everything works fine.
But the problem is in receiving data.
I send a string say "HELLO" as a byte array which is of length 5, but when i receive it on the server, the length of the receieved data in array shows as 8193, i don't understand from where the extra bytes are coming.
And because of these extra bytes my string doesn't match with HELLO.
I have written the same code.
Please having Any Idea.
Also, I want to know how to disconnect the client. It is actually like if the data sent by client doesn't match with that in the server, then i need to disconnect the client and doesn't allow the client Software to run.
Please i am sorry i am asking a lot of Queries.
Thank you again for your code atleast i have got a direction.
I have defined an arraylist with I have populated with objects BIRDS ( the class _birds has only string variabels, with contains information about birds)
ArrayList birdArray = new ArrayList();
loop to populate the birdarray while ((line = sr.ReadLine()) != null) birdArray.Add(new Bird(temptext)); // temptext contains data, which is then parsed into member vars.
This loop fills my ListBox with the german names of the birds in the birdarray, however unsorted
foreach (Bird Vogel in birdArray)
Also I have no idea to retrieve the selected object Vogel, if the user select the german name in the ListBox. Does anybody has a solution how to populate the listbox with a property of objects and then retrieve the objects for further processing. Maybe the arraylist concept is wrong.