|
I have a listbox that I want to databind. How would I get the other fields to show up in text boxes for editing. Say like for a person, have their last name in a listbox, but how would you put first and last name in the listbox and have their attributes such as address, first name, last name, phone, etc.?
I've been unable to find any resources for this, and if you know of any please post.
Thanks
|
|
|
|
|
Hi
I am a beginner in .NET and I am making a program in .NET for communication (TCP) with a other device.
Now I have problems with threads and the tcplistener.
Here is what the program should do:
- a start button (for start listening on specified port)
- a stop button (to close connection and stop listening)
- if I click the start button and a connection is accepted, the connection must be retained untill I click the stop button, because I want to get more messages from my remote device.
Now I have the following code, but it fails to work with a working stop button (form hangs) and it closes my connection everytime the program send the message.
visual basic code:
Imports System.Net.Sockets<br />
Imports System.Text<br />
Imports System.Net<br />
<br />
<br />
Public Class Eventlogger<br />
Const portNumber As Integer = 779<br />
Dim ipAddress As ipAddress = Dns.Resolve("localhost").AddressList(0)<br />
Dim tcpListener = New tcpListener(portNumber)<br />
Private ListenThread<br />
Private parent As frmMain<br />
Private TcpClient As tcpClient<br />
Private password = "test"<br />
Private listening As Boolean = False<br />
<br />
<br />
<br />
Public Sub setParent(ByVal frmMain As frmMain)<br />
parent = frmMain<br />
End Sub<br />
<br />
Public Sub startListening()<br />
parent.btnStartListening.Enabled = False<br />
parent.btnStopListening.Enabled = True<br />
<br />
Console.WriteLine("listener started")<br />
ListenThread = New System.Threading.Thread(AddressOf Listen)<br />
ListenThread.name = "listener"<br />
ListenThread.Start()<br />
listening = True<br />
<br />
<br />
End Sub<br />
<br />
Public Sub stopListening()<br />
parent.btnStartListening.Enabled = True<br />
parent.btnStopListening.Enabled = False<br />
listening = False<br />
<br />
Console.ReadLine()<br />
tcpListener.Stop()<br />
Console.WriteLine("listener stopped")<br />
ListenThread.Join()<br />
<br />
End Sub<br />
<br />
Protected Sub Listen()<br />
While (listening)<br />
tcpListener.Start()<br />
Console.WriteLine("Waiting for connection...")<br />
Try<br />
<br />
<br />
'Accept the pending client connection and return <br />
'a TcpClient initialized for communication. <br />
TcpClient = tcpListener.AcceptTcpClient()<br />
Console.WriteLine("Connection accepted.")<br />
<br />
While (listening)<br />
<br />
<br />
' Get the stream<br />
Dim networkStream As NetworkStream = TcpClient.GetStream()<br />
<br />
<br />
' Read the stream into a byte array<br />
Dim bytes(TcpClient.ReceiveBufferSize) As Byte<br />
networkStream.Read(bytes, 0, CInt(TcpClient.ReceiveBufferSize))<br />
<br />
<br />
<br />
' Return the data received from the client to the console.<br />
Dim clientdata As String = Encoding.ASCII.GetString(bytes)<br />
Console.WriteLine((clientdata))<br />
<br />
If InStr(clientdata, "Password") Then<br />
Dim responseString As String = password & vbCrLf & "status" & vbCrLf<br />
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)<br />
networkStream.Write(sendBytes, 0, sendBytes.Length)<br />
Console.WriteLine(("Password send"))<br />
End If<br />
End While<br />
<br />
<br />
'Dim responseString As String = "Connected to server."<br />
'Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)<br />
'networkStream.Write(sendBytes, 0, sendBytes.Length)<br />
'Console.WriteLine(("Message Sent /> : " + responseString))<br />
<br />
<br />
<br />
'Any communication with the remote client using the TcpClient can go here.<br />
'Close TcpListener and TcpClient.<br />
<br />
<br />
TcpClient.Close()<br />
<br />
Catch e As Exception<br />
Console.WriteLine(e.ToString())<br />
Console.ReadLine()<br />
End Try<br />
End While<br />
<br />
End Sub<br />
Private Sub closeTab()<br />
tcpListener = Nothing<br />
End Sub<br />
<br />
End Class
Could someone give me some hints to help me further with my program?
Christian
|
|
|
|
|
Hi!
I have a VB.NET app needs to be called from an asp page.For that i need a DLL of my app with a simple interface (4 functions and 1 property).How can i do this? I've tried to create a class library with those functions and then add my project, but i can´t use the classes i have there.Is this the correct way to do it?Or do i have to add each of the projects classes to the DLL i´m building?
Thanks in advance.
Never say never
|
|
|
|
|
carlos_rocha wrote:
I've tried to create a class library with those functions and then add my project, but i can´t use the classes i have there
what prob u r facing?
just simply add reference to the assembly and use those funcs in ur project
<< >>
|
|
|
|
|
please gimme the steps and codes to design a currency converter
thank you
|
|
|
|
|
rexford wrote:
gimme
Since this looks like a homework question, I'll help you to understand the problem. You should then have enough information to write your own code based on what ever book you are following or the information provided by your tutor.
Currency conversion is a fairly easy problem to solve. You have a source currency and a destination currency and a conversion factor. This is usually expressed in the format of one unit in the source currency is equal to some units of the destination currency.
For example. £1.00 == €1.46
So, to get from Sterling to Euros (left to right) you multiply the value by 1.46. To get from Euros to Sterling (right to left) you divide by 1.46.
How about if it is expressed the other way around.
€1.00 == £0.68
The calculation is the same (left to right / source to destination) you multiply. To go the other way (right to left / destination to source) you divide.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
There's nothing to this. The most complicated part is getting the current exchange rate for the currencies involved. I don't know of a public source myself, but if you get this data, the rest is easy: TargetCurrency = SourceCurrency * ExchangeRate .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hmm,
Depend what information did you get?
for example you want to know for 50 USA is how much on money on RMB
Frist you need to know 1.00 USD = 8.50 RMB
then using the following equation
A = 1.00 USD_
B = 8.50 RMB_
C = 50.00 USD_
X = ? RMB_
A (USD_) = B (RMB_) --> eq.(1)
C (USD_) = X (RMB_) --> eq.(2)
X = (B/A) * C
You can create a Function to accomplish that.
Hope it will help. If I am wrong please correct me.
|
|
|
|
|
i need help to design a currency converter betwwen two currencies.i need the steps and the codes involed or if possible the tutorials...thank you for helping me.....quami
thank you very much...quami
|
|
|
|
|
hi there,
take a look on this article
Currency converter
it might give u an idea though it's for Pocket...
<< >>
|
|
|
|
|
hiiiiiiii Group
iam going to build a project to monitor and control remote PC, the main points in the project are working with, API, image capturing and networking program. and there are many things other. for now i wanna help to understand these concepts and how to do this with VB.NET.
by the way the program have 2 versions server version for administrator and client version for users.
* The administrator can shutdown, restart, close applications,...., etc.
* The administrator monitors the client screen just by choose the local IP of that client.
* The administrator is provided with reports for the client activities of a period of time
* The administrator defines the previlige of the users on the network (Optional)
these are outlines of my Project, i feel i will learn lot of things with this project.
so anyone have any idea helps me, plz submit it to me or anyone wanna join me with this project i will be happy to share him. so if there any one intersting reply here or contact me via E-mail: mdallal84@yahoo.com
|
|
|
|
|
You do realize you're about the zillionth person to try to re-invent PCAnywhere?
Mdallal84 wrote:
* The administrator can shutdown, restart, close applications,...., etc.
* The administrator monitors the client screen just by choose the local IP of that client.
Well, you're going to need a VNC library to help you handle screen capturing. It's simply the best way to do it.
Mdallal84 wrote:
* The administrator is provided with reports for the client activities of a period of time
Being a LAN guy myself, I really don't see the need for this. But, of course, this depends on what your tracking. I know I wouldn't want to go through reports like this. It's too tedious and time consuming. I've got enough crap to do without babysitting everyone. If I want to monitor someones activities, I'll target that person and turn on the sniffer to catch them red-handed.
Mdallal84 wrote:
* The administrator defines the previlige of the users on the network (Optional)
Totally unneccessary and impractical to implement. This is best done by the proper network administration tools for the directory of the network in question, be it Microsoft's Active Directory, Novell's eDirectory (formerly known as NDS), LDAP, whatever, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
sir/madam,
I am Raju Malladada 2005 Batch CSE branch.I got maore interedted to learn the .NET so Plz help me about it means which book i have to refer and even i don't have the .NET CDs tell me how can i get them.
Raju
Raju malladada
|
|
|
|
|
|
|
Hi, I would really appreciate some advice: I need to create a tree structure in vb (this i can do) and then store and retrieve it from a database (i'm using Access), something similar to a directory structure.
My problem is that the number of levels is unknown - I've tried using a table with category and parentCategory fields and making recursive calls to it, but my algorithm is not working the way it should. If someone has better ideas, please let me know...
Dave
|
|
|
|
|
Yours is a question that requires a long and deep answer. Also it could be handled from several standing points.
If you're looking for an algorithm to serialize a tree I imagine something like one of those.
If your tree is not incredibly deep you could associate at each element a code that represent it's position:
First element: A
Sons of A: AA, AB, AC, ...
Sons of AB: ABA, ABB, ABC
and so on.
Then you could save it in a simple record made of: [data][code]
If you want unlimited branches than this won't work. An idea that works only if you treat data sequentially is:
[data][relationship]
where relationship identify if this member is: root, son of precedent or brother of it.
D/K if it helps.
|
|
|
|
|
Hi,
Is there any away to uncompress the files with extension .tar.Z.
Thanks and advance,
Shiva
|
|
|
|
|
There is nothing in the .NET BCL that'll do this. You have to use a third-party library, like #ziplib[^], to do it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I use Directory.GetFiles to grab the names of files in the specified directory. How can i specify how many of files i need to grab through this command. For example, in a folder have 100 files, but i just need to grab 10 files each time.
Thanks!
|
|
|
|
|
my solution for this is use Directory.GetFiles to get all the files and put into a string array then go through the array to get certain amount of files back.
thanks!
I am Entry level person
|
|
|
|
|
i wrote a simple code as below:
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
' Only get files that begin with the letter "c."
Dim dirs As String() = Directory.GetFiles("C:\Documents and Settings\Max\Desktop\software engineer", "*.ppt")
'MsgBox("The number of files starting with c is {0}." & dirs.Length)
Dim dir As String
Dim i As Integer = 0
For i = 0 To 4
dir += dirs(i)
Label1.Text = dir
Next
Catch ex As Exception
MsgBox("The process failed: {0}", e.ToString())
End Try
End Sub
End Class
I am Entry level person
|
|
|
|
|
Thanks for the reply.
But the problem is the system is slow down with command directory.getfiles when there is a huge number of files in the specified path. The files in that path are accumulating fast.
any idea ?
|
|
|
|
|
You'll have to write your own implementation of .GetFiles() . The one you're using doesn't support just getting X number of files at a time.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks, Dave Kreskowiak!
what is the idea behind this .GetFiles()? Go to path, order those files by creation time, and grab it one by one to x number?
Need your advice, Thanks!
|
|
|
|