|
I am using a winsock control in my app. which create UDP socket.When I send the data using below code-
Dim sendStr As String
sendStr = "hello"
wsClient.SendData sendStr
Then on server side it shows a string of symbols.
But when I send data as-
wsClient.SendData "Hello"
Then on server side it shows "Hello".
What is the problem with first method.
|
|
|
|
|
There is no problem with that code. The two snippets are identical.
The problem would have to be somewhere else, or this isn't the exact code you're using.
Also, are you saying that you're using the old Winsock control, or are you using the socket classes in System.Net?
|
|
|
|
|
Here is what I have so far...
Private WithEvents CurrentDocument As HtmlDocument
Dim MousePoint As Point
Dim Ele As HtmlElement
Private Sub OpenLinkInNewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenLinkInNewWindowToolStripMenuItem.Click
Dim FirstForm As New Form1
FirstForm.Show()
End Sub
Private Sub OpenLinkInNewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenLinkInNewTabToolStripMenuItem.Click
Dim Browser As New WebBrowser
Clipboard.SetText(Ele.GetAttribute("href"))
TabControl1.TabPages.Add("New Tab")
TabControl1.SelectTab(Int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
Int = Int + 1
Browser.IsWebBrowserContextMenuEnabled = False
Browser.ContextMenuStrip = CMenuMain
Me.TabControl1.SelectedTab.Controls.Add(Browser)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Clipboard.GetText)
End Sub
Private Sub CopyLinkLocationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyLinkLocationToolStripMenuItem.Click
Clipboard.SetText(Ele.GetAttribute("href"))
End Sub
Private Sub ViewImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewImageToolStripMenuItem.Click
Dim Browser As New WebBrowser
Clipboard.SetText(Ele.GetAttribute("src"))
TabControl1.TabPages.Add("New Tab")
TabControl1.SelectTab(Int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
Int = Int + 1
Browser.IsWebBrowserContextMenuEnabled = False
Browser.ContextMenuStrip = CMenuMain
Me.TabControl1.SelectedTab.Controls.Add(Browser)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Clipboard.GetText)
End Sub
Private Sub CopyImageLocationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyImageLocationToolStripMenuItem.Click
Clipboard.SetText(Ele.GetAttribute("src"))
End Sub
Private Sub SaveImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveImageToolStripMenuItem.Click
SaveFileDialog2.ShowDialog()
End Sub
I am working on getting the Open Link in New Window, Open Link in New Tab, Copy Link Location, View Image, and Copy Image Location options. How Would I change my code to get them to work?
I used this page to get some of the code Advanced Web Browser Context Menu Tutorial. I did not add certain parts, because they too would not work. They included these...
-------------------------------------------
Now double click your webbrowser, and go to the Navigated event of the webbrowser. Add this code:
CurrentDocument = Browser.Document
This code tells the CurrentDocument HtmlDocument which we just declared to always be the same as the Webbrowser document.
Next go to the Currentdocument.MouseMove event. Add this code:
MousePoint = New Point(e.MousePosition.X, e.MousePosition.Y)
This tells the program to change the record where the mouse is on the document (so it knows where to get the element that the contextmenu has been shown over).
Now, go to the CMenuMain.Opening event, and add this code:
ele = Currentdocument.GetElementFromPoint(MousePoint)
If ele.TagName = "A" Then
OpenLinkInNewWindowToolStripMenuItem.Visible = True
OpenLinkInNewTabToolStripMenuItem.Visible = True
CopyLinkLocationToolStripMenuItem.Visible = True
ToolStripMenuItem29.Visible = True
Else
OpenLinkInNewWindowToolStripMenuItem.Visible = False
OpenLinkInNewTabToolStripMenuItem.Visible = False
CopyLinkLocationToolStripMenuItem.Visible = False
ToolStripMenuItem29.Visible = False
End If
If ele.TagName = "IMG" Then
ViewImageToolStripMenuItem.Visible = True
CopyImageLocationToolStripMenuItem.Visible = True
SaveImageToolStripMenuItem.Visible = True
ToolStripSeparator19.Visible = True
Else
ViewImageToolStripMenuItem.Visible = False
CopyImageLocationToolStripMenuItem.Visible = False
SaveImageToolStripMenuItem.Visible = False
ToolStripSeparator19.Visible = False
End If
This is where ele and MousePoint come into action. This code makes ele (the HtmlElement, say an image, a link or a button) whatever HtmlElement the mouse is over on the webbrowser, because we made MousePoint wherever the mouse was on the document when it moved.
-------------------------------------------
I'd like to implement that code into the project as well, thanks in advance!!
|
|
|
|
|
So you are asking someone to study your code to work out what it does, then you want them to design the changes required to meet a goal you describe in 1 sentence. Note the dramatic lack of response to this question/request. You might do better in the design and architecture forum but I doubt it. This is just asking someone else to do your job for you.
Why don't you propose a solution and see if you get some feedback, or try something and then come back when you meet a problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I tried the bottom part, and it didn't work, I am asking if anyone knew what I needed to do to change it so that it will work in contrast with the top part.
|
|
|
|
|
Code is-
If Text3.Text > 42949672945 Then
MsgBox "Should be between 0 to 4294967295"
When I save it, a # is added to the 42949672945 and code becomes like this-
If Text3.Text > 42949672945# Then
MsgBox "Should be between 0 to 4294967295"
Text3 is a simple data type whose format is Number.
It is the problem of data type that VB does not support.?
Plz guide me what may be the problem?????
Thanks in adv...
|
|
|
|
|
Text3.text is a String data type, so you need to convert that string to a value to do a comparison with your 429....number.
|
|
|
|
|
jainiraj wrote: 42949672945
you should avoid those magic constants. If they are the result of some calculation, just write the calculation; and if there is a symbol for them, use the symbol.
Here you seem to want (1<<32)-1 which is UInt32.MaxValue
Furthermore, 42949672945 isn't an acceptable value, as numeric constants by default are signed integers, so they can't exceed (1<<31)-1 which is Int32.MaxValue
Finally, you need to convert your Text3 content to a number; there are .NET methods for that purpose.
And since you are accepting the entire range of unsigned integer, it can all boil down to:
Dim val as UInt32;
Dim OK as boolean=UInt32.TryParse(Text3.Text, val)
if Not OK Then MsgBox(...)
|
|
|
|
|
Thanks for ur reply..
But it is not working and give an error "No user defined UInt32" data type exist.
Can u help me how to find max length of UInt32??
|
|
|
|
|
System.UInt32.MaxValue
which is 4,294,967,295. The problem with using UInt32 is that it's not CLS-compliant, so you might get some warnings about that.
|
|
|
|
|
Actually problem may be that I am using VB 6.0 and there is no UInt32 data type.
Is it correct??
|
|
|
|
|
yes.
if you are enquiring about VB6 you should put "VB6" in your message and subject line. Always.
|
|
|
|
|
Yep. VB6 has no unsigned integer data types and doesn't have an integer type that supports a number that large. So, it's appending the "#" character to the number to force it to be treated as a Double, which is a floating point type.
I highly suggest abandoning any new developement in VB6 and move to VB.NET.
|
|
|
|
|
Hi,
I am able to extract the text from the PDF file using the PDFStripper, but I would like to read the Table of content of the PDF document. How can I do that? How do I know the Page I am reading is Table of Contents? and also how to differentiate the Chapter heading and the subsection of chapter of the Table of Content?
Any help in this is highly appreciated.
Thanks
Neil
|
|
|
|
|
Do NOT cross post in multiple forums. I makes collaborating on an answer near impossible.
|
|
|
|
|
I have found a code from the net, but its not working properly.
It is related to UDP socket creation.
Senario is like when we click on "send data" button a "hello" string should pass from client to server which are on the same machine.
Problem is when I click on "send data" button it gives an error-
code is-
Private Sub Form_Load()
' Set the control objects when the form loads.
Set wsClient = Me!axWinsockClient.Object
Set wsServer = Me!axWinsockServer.Object
' Set the protocol for client and server.
wsClient.Protocol = sckUDPProtocol
wsServer.Protocol = sckUDPProtocol
' Set the host and ports for client and server. Because client
' and server are the same computer in this example, set RemoteHost
' equal to LocalIP.
wsServer.RemoteHost = wsClient.LocalIP
wsServer.RemotePort = 1007
wsClient.Bind 1007
End Sub
Private Sub CmdSend_Click()
' Send a broadcast message from the server.
wsServer.SendData "Hello"
End Sub
Private Sub axWinsockClient_DataArrival(ByVal bytesTotal As Long)
Dim strServerMsg As String
' When a message arrives from the server, display it in a text
' box.
wsClient.GetData strServerMsg, vbString
Me!Text1.Value = strServerMsg
End Sub
Here axWinsockClient and axWinsockServer are the socket control or winsock on the same form. and "hello" string should be print in text box.
On debugging I found it is not calling axWinsockClient_DataArrival() method.
What may be the problem.
Thnks in adv..
modified on Friday, September 3, 2010 8:11 AM
|
|
|
|
|
You left out the most important part of the question. WHAT'S THE ERROR YOU'RE GETTING??
|
|
|
|
|
|
Perhaps you should post what the error was and what you did to fix it so that other people with the same problem can benefit from your post
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
Give him a break, he was just reminded about errors.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
I wasn't trying to be sarcastic, but someone could actually benefit from it
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
Somehow, I doubt it. If all it took was to read the eorror message, I think the solution was obvious from whatever the message was.
|
|
|
|
|
Yeah good point, sorry
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
|
No I am not going to click a suspicious link.
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|