|
You said much, but nothing useful to diagnose the problem. We'd have to see the code the you're using to both send and receive the information. TCP?? So you've implemented a socket server and client in your app??
|
|
|
|
|
Here is my code
Sending code
Public Sub Send(ByVal dataToSend As String)
Try
bytesToSend() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(dataToSend)
mysocket.Send(bytesToSend,0,bytesToSend.Length)
Catch se as SocketException
MsgBox(se.ToString)
End Try
End Sub
Receiving
Private Class StateClass
Public clientSocket As Socket
Public clientBuffer() As Byte ------> how do i know the buffer size before hand
End Sub
Public Sub OnAcceptConnection(ByVal result as IAsyncResult)
Dim state as New stateClass
Dim serverSocket As Socket = CType(result.AsyncState, Socket)
Try
state.clientSocket = serverSocet.EndAccept(result)
state.clientSocket.BeginReceive(state.clientBuffer,0,state.clientBuffer.Length,SocketFlags.None, _
New AsyncCallback(AddressOf ReceiveCallback,stateClass)
Catch acceptex as Exception
MsgBox(acceptex.ToString)
EndTry
EndSub
Private ReceiveCallback(ByVal result2 as IAsyncResult)
Try
Dim state As stateClass,CType(result2.AyncState,stateClass)
Dim numberBytesRead As Int32 = state.clientSocket.EndReceive(result2)
If numberBytesRead >0 Then
Dim receivedString As String = ASCII.GetString(state.clientBuffer)
Console.WriteLine(receivedString)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
|
|
|
|
|
captainmogo wrote: Private Class StateClass
Public clientSocket As Socket
Public clientBuffer() As Byte ------> how do i know the buffer size before hand
End Sub
You don't let this size be variable, you set it to a static value, say 4K. You'll have to adjust this size for your own requirements.
Private Class StateClass
Public clientSocket As Socket
Public clientBuffer(4096) As Byte
End Class
|
|
|
|
|
If I set it to, say 4k and the message that I am sending is larger than that - it wont get all of it unless I loop it with .BeginReceive again. I have tried that in the past and still have not gotten it to work properly. The .BeginReceive never fires a second time. I am not sure what I am doing wrong which is why I was hoping there was a good example out there. I have 4 channels each of very different size but only 1 stateclass - so how do i adjust it to fit each channel. Is this even possible.
|
|
|
|
|
captainmogo wrote: it wont get all of it unless I loop it with .BeginReceive again. I have tried that in the past and still have not gotten it to work properly. The .BeginReceive never fires a second time.
This is because you have to setup another Async Begin Read at the end of your ReceiveCallback.
Private Sub ReceiveCallback(yada)
yada, yada, yada
' Convert another chunk of the data to whatever you need...
' Invoke any control update methods you need...
' and last but not least, setup and fire off another BeginRead...
StartAsyncRead()
End Sub
StartAsyncRead is where you create a State object and call the BeginRead method again.
captainmogo wrote: I have 4 channels each of very different size but only 1 stateclass - so how do i adjust it to fit each channel.
The buffer size has to be big enough to hold either an entire message. OR the code breaking down the message into bytes has to fit as much as it can in the buffer and wait for another chance to send the next chunk. OR you leave it a variable size and ReDim the buffer to a known size defore you fill it. OR you could even just create 4 different size State classes.
|
|
|
|
|
Hi, I currently using VB.NET with Rich Text Box control, if focus my cursor wherever, can i get high light background? (example if i focus in column 2 it will high light only column 2).
Socheat
|
|
|
|
|
There's a problem with that. There is no "column 2". The RTB doesn't have columns, just lines, which can span multiple visible rows in the RTB and characters in that line.
For instance, in the RTB, this is one line (if there is no carriage return entered anywhere in the text):
--This is one line. This is one line. This is one
line. This is one line. This is one line. This is
one line. This is one line. This is one line. Thi
s is one line. This is one line. This is one line
. This is one line. This is one line. This is one
line. This is one line. This is one line. This i
s one line. This is one line. This is one line.[ENTER]
Now, your code could go through every line in the RTB and highlight the second character of each line, but in the above example, only one character would get highlighted, the second one on the first row of characters. Line two doesn't begin until after the [ENTER].
|
|
|
|
|
Below are my codes
Dim Position As Integer = Me.RichTextBoxMy.SelectionStart
Dim Line As Integer = Me.RichTextBoxMy.GetLineFromCharIndex(Position) + 1
Dim Col As Integer = Position - Me.RichTextBoxMy.GetFirstCharIndexOfCurrentLine + 1
Codes above I can get Column and Line from RTB
If i have many line and if I focus in one line that i can get from RTB, do you know how to highlight background for that line only, if cursor move to other it will highlight other too.
Would you mind give me a example code?
Thanks
-- modified at 10:45 Saturday 6th October, 2007
Socheat
|
|
|
|
|
Hello Everybody
Im doing a Library Project for my college. Need some guideline follows.........
Is it possible all information contain a MDIParent page, Like when I click AddNewMember then the frmAddNewMember form will be appear on (MDIParrent Dock Fill) after fill up this form a confirmation page will be come with a NewMemberID which will be appear on (Dock Fill). If you have a look on Microsoft Office Outlook then you will understand what I want to do.
Any instruction will be really helpful.
Sarfarj Ahmed
|
|
|
|
|
From the description, you don't need an MDI app to do this.
Sarfaraj Ahmed wrote: If you have a look on Microsoft Office Outlook then you will understand what I want to do.
I use Outlook and, no, I still have no idea what you want to do other than fill in the fields of a form. Why would you want to use an MDI form to do this?
|
|
|
|
|
Thanks,
I have Designed my project
I have two panel on my project. Left panel contain manu like add newMember, newBook, borrowBook, returnBook etc. When I will click any option then Right Panel will fill that information like newMemberRegister form, borrowBook form.
like function newMember()
when I will call this function then Right Panel will fill frmNewMember
any idea?
Thanks
Sarfaraj
Sarfarj Ahmed
|
|
|
|
|
You don't need an MDI form to do this. Among newbies, MDI is probably the second most abused idea, next to using a PictureBox to draw everything.
Make up your forms as normal. When you need to create a form and show it in the panel, you do something like this:
Dim currentForm As New BorrowBookForm()
currentForm.TopLevel = False
RightSidePanel.Controls.Add(currentForm)
You'll have to manage keeping only one form in that panel and destroying the previous form before putting the new one in the Panel. This is because if you don't, you'll run the system out of resources due to exhaustion of the handle pool.
|
|
|
|
|
Dear Dave
what I done is , I have add two form on the project form1 and form2
form on:
I have taken two panel panel1 and panel2
On panel1 i have add a button and panel2 is empty. On button click event i wrote code you given
Dim currentForm As New form2()
currentForm.TopLevel = False
panel2.Controls.Add(currentForm)
But can't see the form2 on panel2. waiting for your reply
Sarfarj Ahmed
|
|
|
|
|
So much for the ability to do research...
currentForm.Show()
|
|
|
|
|
Dave
Thanks a lot. it does work. Dave I got question, Im doing a Library Mangement Project and it has to be desktop and internet based. Basically Member can login on internet, they can view their report. But in the library it has to be really fast. Also I have to maintain same server for desktop and internet. library will get Intranet connection and member will get internet connection.
wot your suggestion
waiting for your reply
Sarfarj Ahmed
|
|
|
|
|
Sarfaraj Ahmed wrote: wot your suggestion
Suggestion for what??
|
|
|
|
|
Thanks For Replying ,
Hi , now i am using my own custom propertygrid for runtime controls when i am clicking on textbox it is showing properties . I am showing font,backcolor,location ,like some properties
1) How to create the wordwrap,TextAlign properties .
2) Now the problem arises with borderstyle ,Multiline and some other Properties while selecting textbox, I am not able to set these properties .These are not there by default for runtime ctr.I created the properties for borderstyle,. I dont know how to create the property for TextAlign . NOt Coming with (System.Win.Forms.TextboxBase)
.Dim ctr as control --- TRhen i am getting properties butnot borderstyle,textalign ,etc
3) In PropertyGrid1_PropertyValueChanged , i am writing like this
Case "Font"<br />
ctr.Font = e.ChangedItem.Value<br />
Select Case e.ChangedItem.Label<br />
<br />
Case "BackColor"<br />
ctr.BackColor = e.ChangedItem.Value<br />
<br />
Case "BorderStyle"<br />
if ctype(sender,TextBox) then '''Borderstyle not coming <br />
ctr.BorderStyle( Not Coming) = e.ChangedItem.Value <br />
<br />
Dim ctr As New TextBox ''If i use like this only borderstyle is coming "<br />
ctr.BorderStyle( Coming) = e.ChangedItem.Value ' but Not working
waiting For Reply ......
DVSriram
|
|
|
|
|
Hi,
I am not sure about your problem. If I create a form with a textbox and a PropertyGrid, all the textbox properties that you mentioned are in the grid. I see no issue.
Also what do you mean by "custom PropertyGrid" ?
|
|
|
|
|
I am using the following code to send mail but it fails with message below
System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040213): The transport failed to connect to the server.
/////////////////////////////// Code //////////////////////////////////////////////////////////
Imports System.Web.Mail
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
Dim oMsg As MailMessage = New MailMessage
oMsg.From = "from@gmail.com"
oMsg.To = "to@alumnux.com"
oMsg.Subject = "Test Mail from soumya"
oMsg.BodyFormat = MailFormat.Html
oMsg.Body = "Hellow World "
SmtpMail.SmtpServer = "smtp.gmail.com"
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com")
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "587")
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true") 'set your password here
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "user@gmail.com") 'set your username here
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password") 'set your password here
SmtpMail.Send(oMsg)
oMsg = Nothing
End Sub
End Class
|
|
|
|
|
|
Thanks a lot for your reply.I have read this tutorial and i am sure this will work work successfully but one problem is this tutorial is developed in .NET Framework 3.0 so how can do the list below:
1. Currently 1.1 is installed
2. I have downloaded 3.0 and installed it.
3. How can i switch to 3.0 without uninstalling 1.1
4. I am using visual studio 7.0
|
|
|
|
|
How can i get back column data from the dataset which i created.
The problem is that i have a table in the table second column i have some data but the table is in the dataset pl z tell me the technique how can i get it back.
|
|
|
|
|
A DataSet has a Tables collection. A Table has a Columns collection.
Use these to get the information you need.
Paul Marfleet
|
|
|
|
|
Can any one help me to make a Attendance register that will record all Attandance of employees of my company. and on that basis i will generate the payroll. I have already tried a solution that will create Monthly Tables in Access example
Table name will be : EMPLOYEENAME/MONTH (ABC/FEB-07)
but this will be a lot space consuming. i want to try a diffrent solutions sample projects will be appreciated Please Help Guys.
Hefin Dsouza
|
|
|
|
|
This is a pretty straight forward task. Which bit are you worried about ? you want to create one table for all employees, and another that tracks attendance.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|