|
Yes Picturebox and Panel in Groupbox.
If you can think then I Can.
|
|
|
|
|
And what are you showing in the PictureBox and what's going on with the Panel?
|
|
|
|
|
I've posted this up on the MSDN in the VB section and it has sat there receiving 55 views and still no answers or suggestions. I'm hoping that maybe someone here can help me understand it and help me find a solution. Now, I've gone and I've bought at least 300 dollars worth of books and tried every example I could find on the internet and tried to learn on my own, but I've hit a snag that requires some expertise. I do not claim to be a great VB programmer, but I'm hoping that my skill will increase with time. It took a friend of mine 5 years to master C programming, and after he mastered it, it only took him 3 months to master C++ and C#. So, I have hope that I'll master VB faster than he mastered C.
I have read - recently - many topics concerning the connection of TCP/IP connecting versus using the old winsck connecting method. Currently, I'm in the middle of a project and I'm completely lost as to which direction to go because I've tried both directions (winsck & TCP/IP) without any sort of avail. Currently, I am attempting to create my own mud client (as a reference, you could look at Nerdy Mud Client @ SourceForge - I'm trying to recreate the VB6 project using VB 2008 EE). Thus far, I've been able to appropriately get my forms together and working the way I wanted them. I've got the main form, with a window where the text output should be, I've got a text input bar and set it to AcceptsReturn True so people can type a message into the bar and hit enter to submit it, but for some reason, I can't get it to connect at all. I'd like it to actually connect to "legendsofkrynn.wolfpaw.net:6100." I keep finding tutorials on creating P2P chat clients and FTP clients, but that's not what I want. I want my client to talk to the server and receive information from the server, as well as send user input commands to the server. Currently, this is the code that I've got for my connection method.
'Connects to legendsofkrynn.wolfpaw.net:6100
Private Sub ConnectToolStripMenuItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ConnectToolStripMenuItem.Click
winsock1.Connect("legendsofkrynn.wolfpaw.net", 6100)
End Sub
Unfortunately, if this connects, it won't display the output into my mudViewer form (which is just a regular textbox set to multiline = true). Unfortunately as well, if this doesn't connect, I have no way to figure it out. Now, I've also tried....
Import System
Import System.Net.Sockets
At the top of the code is where I put that part, and then I used the same code for my winsock1 connect as before, and still nothing. Then I figured out that you probably shouldn't use the winsck controller with the Imports. So, I used the Imports again and then attempted this code.
'Connects to legendsofkrynn.wolfpaw.net:6100
Private Sub ConnectToolStripMenuItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ConnectToolStripMenuItem.Click
myTCPClient.Connect("legendsofkrynn.wolfpaw.net", 6100)
End Sub
And, unfortunately, it still did not work. Now. I'm very well aware that I'm still an incredibly large nooblet when it comes to VB and this is actually a rather large project for someone of Beginner skill to take on, but I'd really like to figure this out and get it working. Is there anyone that could offer me some good advice? Most of the tutorials I have found are only for P2P chat clients, and FTP transfer clients - as previously stated. Can anyone please, please please help me understand it? Now, my project is INCREDIBLY BASIC at this point in time. Here's the full code for the primary form.
Public Class mudclient
'Closes the entire client because the client MDI = true.
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
'Shows the current system clock time.
Private Sub btnMenuTimer_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnMenuTimer.Tick
btnMenuClock.Text = TimeOfDay
End Sub
'Opens the options dialogue.
Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles OptionsToolStripMenuItem.Click
options.ShowDialog()
End Sub
'Shows the Event Calendar for Scheduled or Notated Events.
Private Sub btnEvent_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnEvent.Click
eventScheduler.Show()
End Sub
'Connects to legendsofkrynn.wolfpaw.net:6100
Private Sub ConnectToolStripMenuItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ConnectToolStripMenuItem.Click
winsock1.Connect("legendsofkrynn.wolfpaw.net", 6100)
End Sub
'Disconnects from legendsofkrynn.wolfpaw.net:6100
Private Sub DisconnectToolStripMenuItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DisconnectToolStripMenuItem.Click
End Sub
End Class
Can anyone please help me?
|
|
|
|
|
Having no actual experience myself, with what you are trying to do, here is a couple of thoughts that may help:
- Attempt the actual connection in a Try Catch block with msgbox(ex.tostring) to first find out if it really is not connecting, or if there is simply some error in the code.
- Does the .Connect method in your winsock code example return a value? If so, the return value may tell you why the connection fails / is refused. You can step through the code, or perhaps you can show the return value (if there is one) in a messagebox as well.
- Almost all remote connections require some sort of identification (username / password). Have you checked if maybe the connection simply wants you to supply such information?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Johan made some good suggestions in the other post, but more can't hurt...
You posted the connection code, which may or may not be working, but where's the code that does the actual I/O? The code that sends the user-entered text, and the code that displays the incoming data? If that code has errors, it would explain why you aren't seeing any output.
Socket programming can be a little complicated for beginners, mainly because you generally use a second thread to watch for output, and you have to parse out individual messages from the network stream.
|
|
|
|
|
You're showing the code for the form , but you're not showing ANY of the TCP handling code at all. If all you have is a call to Connect, and nothing else, then it's not surprising you're not seeing anything come back. You don't have any code handing any of the received data and putting in in the textbox.
|
|
|
|
|
Everyone,
Thank you so much for your suggestions! Johan, I actually did not think of that. I don't have any block for winsck that would show whether or not the connection was connected or not. Ian and Dave, I did not think of having code to handle the I/O. The basic concept is that I want this one client to connect to the remove server (legendsofkrynn.wolfpaw.net) on the specified port (6100). So it would make sense that there would need to be something that needed to handle the I/O. Would you recommend I use a module or a class for the I/O handling? Also, which would actually be more prudent to use in my current quest? Winsck or TCP/IP? Many people say that with the development of VB 2008, there's no longer a need to use winsck, would anyone agree?
|
|
|
|
|
The general rule is that when you're programming a .NET language, try to stay within the .NET framework and .NET-based libraries (aka "Managed code") unless you really need to do otherwise. Hence, don't use winsock directly. Use a TcpClient. The winsock DLLs are pretty much obsolete anyway, I believe.
I do suggest, though, that if this is your first foray into programming, you pick a simpler project. Network clients aren't incredibly complicated, but they pull in several concepts that are a little above the beginner level.
Here's the brief summary of what you need to do:
1) Get the network stream from the GetStream() function. This is an abstraction of the "pipe" you use to read and write data from the network.
2) To simplify access to this stream, create a System.IO.StreamReader. This does all the work of buffering the incoming data, splitting it into discrete messages, and letting you read one line at a time.
3) Create a background thread to watch the streamreader and read the incoming data. Look up System.Threading.ThreadPool.QueueUserWorkItem for a "safe" way to do it. If you're not familiar with the concept, having an extra thread is basically like running two parts of the program at the same time (Sort of). The background thread will keep watching the network for incoming data.
4) Have the background thread loop on the streamreader's ReadLine() function, to get the actual data.
5) When it gets a line, Invoke to the GUI thread (This is needed, because background threads can't touch GUI controls) and add the line to your text box.
Those five steps will let you see the data coming in from the network... Sending data is actually a lot easier...
1) Create a StreamWriter on the same stream in the first step above.
2) When the user presses enter in the input box, grab the text from that box and use the StreamWriter's WriteLine() method, followed by Flush() (Flush makes sure the data actually gets sent, instead of waiting in a buffer).
3) Also add that text to the output window, since MUD clients expect you to echo the data you send.
I've bolded some of the keywords, so you know what to look up in your references... But like I said, this is a bit above beginner level, so take your time and keep google handy.
|
|
|
|
|
Ian,
This is some really great advice! Thanks so much for writing it for me. So far, I'm shocked and surprised that I get more help here than I do on the MSDN official VB forums with Microsoft, heh. I'm definitely checking into these things as of right this moment. Now, I do have a question, do you think it would be more beneficial for me to modulate the your suggestions, or should I privatize them and make them classes? Also, I'm including code below - upgraded I/O module - from Nerdy Mud Clients source code. Should I attempt to just copy/paste and credit that portion of the code to Nerdy, or are your suggestions above suggestions for I/O? I know that sounds like a stupid question and I apologize if it makes me look even more noobish. I know this project is definitely above my level, but I'm fully committed to seeing it through. To me, I feel that it's better to tackle something difficult and learn as much from it as possible than to keep with the smaller projects and learn little by little. Backwards logic, I know.
Option Strict Off
Option Explicit On
Module mdlDataIO
Dim cmdhistRow As Short
Dim cmdhistNewPos As Short
Dim cmdHistTmp As String
Public arraycmdhist(30) As String
Public Sub multisend(ByRef txt2send As String)
frmMain.Winsock1.SendData(txt2send & vbCr)
End Sub
Public Sub File2Combo(ByRef sfile As String, _
ByRef oList As System.Windows.Forms.ComboBox) _
'this has been relocated from frmmain to help modularize and clean up code
'it should be stable and complete
Dim fnum As Short
Dim sTemp As String
fnum = FreeFile()
oList.Items.Clear()
FileOpen(fnum, sfile, OpenMode.Input)
While Not EOF(fnum)
sTemp = LineInput(fnum)
oList.Items.Add(sTemp)
End While
FileClose(fnum)
End Sub
Public Sub cmdHistScrollup() 'stable/finalized
If CDbl(frmMain.lblSBH.Text) = 30 Then frmMain.lblSBH.Text = CStr(0)
If arraycmdhist(CInt(frmMain.lblSBH.Text)) = "" Then
Do While arraycmdhist(CInt(frmMain.lblSBH.Text)) = "" _
And CDbl(frmMain.lblSBH.Text) < 30
frmMain.lblSBH.Text = CStr(CDbl(frmMain.lblSBH.Text) + 1)
Loop
End If
frmMain.txtInput.Text = arraycmdhist(CInt(frmMain.lblSBH.Text))
If CDbl(frmMain.lblSBH.Text) <= 29 Then frmMain.lblSBH.Text = _
CStr(CDbl(frmMain.lblSBH.Text) + 1)
End Sub
Public Sub cmdhistscrollDown()
If CDbl(frmMain.lblSBH.Text) = 0 Then frmMain.lblSBH.Text = CStr(30)
If arraycmdhist(CInt(frmMain.lblSBH.Text)) = "" Then
Do While arraycmdhist(CInt(frmMain.lblSBH.Text)) = "" _
And CDbl(frmMain.lblSBH.Text) > 0
frmMain.lblSBH.Text = CStr(CDbl(frmMain.lblSBH.Text) - 1)
Loop
End If
frmMain.txtInput.Text = arraycmdhist(CInt(frmMain.lblSBH.Text))
If CDbl(frmMain.lblSBH.Text) >= 1 Then frmMain.lblSBH.Text = _
CStr(CDbl(frmMain.lblSBH.Text) - 1)
End Sub
End Module
|
|
|
|
|
Ok, one thing at a time...
1) Forget modules. That's a VB6 thing. The closest parallel is a "static class", which for something like this, you don't need.
2) The code you posted is something else entirely... You don't need that at all.
Basically, here's the interface I would suggest (Not spoon-feeding the code - Just setting up a layout):
Public Class ServerConnection
Public Property IsConnected as Boolean
Get
Private Set
End Property
Public Sub Connect(ByVal address as String, ByVal port as Long)
End Sub
Public Sub Disconnect(ByVal address as String, ByVal port as Long)
End Sub
Public Sub SendMessage(ByVal message as String)
End Sub
Public Event MessageReceived(ByVal sender as Object, ByVal message as String)
End Class
This is just the interface... It's up to you to implement it. The idea is that only this class actually knows how the data is going back and forth, so everything not shown here is set as Private. The rest of your application can just send and receive messages simply, without having to know the details. The term for this is "encapsulation", and it's one of the staples of object-oriented programming.
Granted, you could put all of the code in the same file as your form, but if you start out with a good design structure, it makes it easier to add to it later, and much easier to read.
As for putting the results in a textbox... Well, that part is a lot simpler.
|
|
|
|
|
hi expert
my question is reletant to listview control. i want to move listview control in runtime.
ex. suppose same data in listview and i want to move listview control because back of listview conrol same item define.
|
|
|
|
|
I am sorry, I cannot understand this. Please clarify. Do you want to move the control, move the scrollbar within the control, move items around inside the control, or something else ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
as far as i can understand your question you want to move(Drag and place) the Listview control on to doffrent place at run time. If it is so yoe can use MouseMove and MouseDown events of the list view to perform the task.
or if your question is somthing diffrent then please ask your question in details.
Good luck.
Regards,
Paramhans Dubey.
|
|
|
|
|
I am planning on developing a software in VB.Net that will monitor telephone calls made by workers in a office. Can someone please help me out with how to go about it? Thanks
|
|
|
|
|
Well, your first step would be to do some research into ways that you might expect to interact with a particular type of phone system, if you have a specific office in mind, or what phone systems you CAN interact with, if you're writing something generic. If you have a specific office in mind, I doubt very much that all, or even most, phone systems can be monitored in code.
Then your next step is to write some code. Your final step is to ask specific questions here if you get stuck. This smells of someone bidding on a rentacoder job, then asking here how it is done.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
On top of what Christian said, you also have to deal with legal issues. In the US, unless you specifically spell out this policy and notify BOTH parties on the line that the call can be monitored at the beginning of the call, you cannot legally monitor the call.
|
|
|
|
|
hi all,
Please help me to solve the following problem.
Today i am in trying to send an exe file to my client through e-mail. I attached the same and sent the mail successfully, and asked my client to download the same. But my client found the mail without any attachment.I repeated the same atleast 4 time but my client could not find any attachment.
i could not understand, What is the reason?
Kindly help me.
Thanks
Rafiq
rmshah
Developer
|
|
|
|
|
This is plainly not a programming question. His mail server is probably stripping it. Use yousendit to deliver executables. Gmail for one definitely will not send any exe, even in a zip.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
As Christian said, Gmail does not accept EXE files as attachments (not even inside a ZIP); however it suffices to modify the file extension to say EXE2. I trust some other mail systems have the same policy.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
.NET memory encreasing (GetBitmapBits)
I am creating an application for my Logitech G19 keyboard with a LCD screen.
First i created a bitmap where i put some information on (such as text) to put on my lcd screen.
Dim bmpNet As Bitmap
...etc...etc... put information, text...etc...
Then, i have to convert the bitmap to bytes/intptr as the following line says with GetBitmapBits:
GetBitmapBits(bmpNet.GetHbitmap, lcdBMPQVGAx32.pixels.Length, lcdBMPQVGAx32.pixels)
Function is declere on top of my source code as:
<DllImport("gdi32.dll", CharSet:=CharSet.Auto, SetLastError:=True, ExactSpelling:=True)> _
Public Shared Function GetBitmapBits(ByVal hbmp As IntPtr, ByVal cbBuffer As Integer, ByVal lpvBits As Byte()) As Integer
End Function
Now, every time GetBitmapBits invokes, the memory of my application will encrease with 200kB/300kB. I have a timer ticking, so the memory will encrease every, 2 a 3 seconds.
Can someone help me with this problem?
Thanks in advance.
Colin Raaijmakers
|
|
|
|
|
Hi,
this is hard to diagnose as you haven't shown much of the code.
I don't think GetBitmapBits() is wasting any memory, it seems more like a copy operation, it does not allocate any memory. However it needs an lpvBits parameter, i.e. a pointer to the destination buffer. I guess your code, probably the couple of lines above the call to GetBitmapBits, allocates a new buffer each time and those buffers are not released and collected in time.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
hi,
make sure you destroy the pointer you retrieve from GetBitmapBits every time you call the function.
|
|
|
|
|
That will be: lcdBMPQVGAx32.pixels
and yes, i am destroying it with "lcdBMPQVGAx32.pixels = nothing".
Tried anything, but it's not working...
|
|
|
|
|
Hi i am a new software student i need help on programm this project,it consist of two teams Vocational’ and ‘Academic’ teams competting against each other and the game they play are
• Chess
• Spelling
• General knowledge
• Each match is ‘best of three’ single games of one type of game
• Staff/students cannot play other members from the same department
• Team members of each team can only play another team member once
• Each team member will take part in one match for each type of game.
To allow results to be entered, the aim of the program is to
• Prepare a list of matches for the games competition
• Identify the winners of each match on the schedule
• Calculate the points awarded to each House
This will allow the Principal to present the Most Intellectual Cup to the most successful team in the college at the end of the day.
The program must be thoroughly tested before the games competition starts.
These are the specific requirements for your programme:
• The interface must use the following colours:
o Vocational – green
o Academic – blue
Data for Games day
Staff/students and their team
Total in Academic team is 18 Total in Vocational team is 18
Total pupils is 36
|
|
|
|
|
Help with what? You haven't asked a question. Which part of this pile of specs are you stuck on?
|
|
|
|
|