|
Dim tcpcli As New Net.Sockets.TcpClient(New Net.IPEndPoint(Net.IPAddress.Parse("192.112.10.116"), 2001))
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
When I do this I get this error?
The requested address is not valid in its context.
I can't figure it out. Any Ideas.
|
|
|
|
|
can your computer get to that address? ex: \\192.168... or can you ping it?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Yes, I can ping and access a shared folder on the device which is a barcode scanner with Windows CE. I don't think that would make a difference.
|
|
|
|
|
????
google "The requested address is not valid in its context" and see what the fix is...
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Can you walk me through how Sockets work? Maybe I am trying to do something and it is wrong. This is what I think my code is trying to do. Correct me if I am wrong.
Server Side
Listener code 'Most of this code I found in a book.
Dim localhostAddress As IPAddress = IPAddress.Loopback
Dim tcpList As New TcpListener(localhostAddress, 2048) 'I just picked a port not already being used.
tcpList.Start()
Do
Dim tcpcli As TcpClient = tcpList.AcceptTcpClient
Dim ns As NetworkStream = tcpcli.GetStream
Dim sr As New StreamReader(ns)
Dim receivedData As String = sr.ReadLine()
Dim result As Boolean
If receivedData <> "" Then
'Test the received data to see which function to call
If receivedData = "BUYER" Then
result = desktop.getBuyers()
ElseIf receivedData = "SHIP" Then
result = desktop.updateShip()
ElseIf receivedData = "MOVE" Then
result = desktop.updateMove()
ElseIf receivedData = "PHYINV" Then
result = desktop.updatePhyInv()
End If
'Send result
SendData(ns, result)
End If
sr.Close()
ns.Close()
tcpcli.Close()
If receivedData = "" Then Exit Do
Loop
tcpList.Stop()
Client side code I want to send data across a wireless device to my pc to my running application. Is this code on the right track?
<code>Dim sock As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim ipep As IPEndPoint = New IPEndPoint(IPAddress.Parse("110.156.10.116"), 2048)
sock.Connect(ipep)
Dim ns As NetworkStream = New NetworkStream(sock)
Dim sw As New StreamWriter(ns)
sw.WriteLine("BUYER")
sw.Flush()
Dim result As String = ReadData(ns)
sw.Close()
ns.Close()
If result <> "" Then Exit Do
Loop
</code>
The above IP for the socket is to my pc. Does the port have to match the one it is going to on the other end?
Any help is appreciated.
|
|
|
|
|
Hi,
I am using VB to grab information from Monarch Pro and output it into a printable format, I have been putting it into a txt file and need a way to input a page break into the output, I am able to use Word if that helps. I can also use other methods of parcing the data, I just need a little push in the right direction, it would be best to put the information into a format that a user could open,print and go.
|
|
|
|
|
Chris Dykes wrote: I have been putting it into a txt file and need a way to input a page break into the output,
There is no such thing as a pagebreak in a text file. The closest you're going to get is the FormFeed character (ASCII code 12). Of course, there are other formats you could use besides straight text. But, keep in mind that pagebreaks are a function of the application doing the printing, not of the document. The document needs to convey that there should be a pagebreak at a certain point in the document and signal that by including the appropriate formatting codes in the file. Exactly how to do this depends on the file format chosen and the application printing it.
|
|
|
|
|
So if I use Word to print the document I would format it to what Word requires for page breaks?
|
|
|
|
|
You'd more than likely be using Word's object model to build the document, which will probably include a method to insert a pagebreak.
|
|
|
|
|
Hi,
I'm a little confused about sending a variable into a function ByVal. I've always understood it that if you send it by value the program will make a copy of the variable and anything you do to that variable inside the function will not affect the original one. Thing is my code seems to contradict this. (i hate it when people post loads of code so i've simplified it)
class SomeClass
' a ticket has a property .Message which is a Mymailer.Message
private ticket as MyMailer.Ticket
private function DoSomething(ByVal message as MyMailer.Message) as Mymailer.Message
message.Subject = "Test subject"
message.Body = "This is a test message"
return message
end function
private sub SomeSubroutine()
dim newMessage as MyMailer.Message = DoMailMerge(ticket.Message)
end sub
end class
for some reason when i call SomeSubroutine() the message contained in the variable 'ticket' is changed, even though i passed it by value.
can anyone see why the variable ticket would be affected?
it works if the DoSomething function is:
private function DoSomething(ByVal message as MyMailer.Message) as Mymailer.Message
dim subject as string = "TestSubject"
dim body as string = "This is a test message"
dim newmessage as new MyMailer.Message
newmessage.Subject = subject
newmessage.Body = body
return newmessage
end function
kevin
|
|
|
|
|
If your object is a reference type ( a class ) then ByVal means nothing, it's always ByRef
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Objects and arrays are reference types. Basically an object is a pointer to a structure and the name of the object is essentially a pointer/reference. So when you pass them byval the compiler makes a copy of the pointer/reference but both copies point to the same "structure". That's why any change made by one will affect the other.
|
|
|
|
|
Thanks Christian and Mike. Now I understand!
|
|
|
|
|
Hi,
I have the following code which I converted fro c#. Any time I run it I get an error at the con.open()
This is the error
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
Here is the code
Private Sub LookupDB(ByVal PartNum As String)<br />
Dim ConnectString As String = "user id=****;password=****;initial catalog=eLibrarian;data source=" & "*******"<br />
Dim con As SqlConnection = New SqlConnection(ConnectString)<br />
<br />
Dim cmd As SqlCommand = New SqlCommand("pGetSWEETFileAttributes", con)<br />
<br />
cmd.CommandType = CommandType.StoredProcedure<br />
<br />
'<br />
' Initialise parameters to database stored procedure:<br />
'<br />
' 1. Input Parameter representing Part Number<br />
'<br />
Dim param As SqlParameter = New SqlParameter("@inparam_ElementID", SqlDbType.VarChar, 50)<br />
<br />
param.Direction = ParameterDirection.Input<br />
<br />
param.Value = PartNum<br />
<br />
cmd.Parameters.Add(param)<br />
'<br />
' Read from database<br />
'<br />
con.Open()<br />
<br />
<br />
Dim reader As SqlDataReader = cmd.ExecuteReader() 'ExecuteNonQuery();<br />
<br />
Dim record_count As Integer = 0<br />
While reader.Read()<br />
txtSize.Text = reader("FileSize").ToString()<br />
txtMD5.Text = reader("MD5Checksum").ToString()<br />
record_count = record_count + 1<br />
End While<br />
reader.Close()<br />
con.Close()<br />
<br />
If record_count = 0 Then<br />
Throw New Exception("Part number " + PartNum + " not found in dataMyBase. Please enter the filesize and MD5 checksum")<br />
End If<br />
<br />
End Sub
|
|
|
|
|
johnjsm wrote: Dim ConnectString As String = "user id=****;password=****;initial catalog=eLibrarian;data source=" & "*******"
I assume this is not the actual code, you changed it to post it ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am trying to use remoting for an application I am writing. One problem with remoting is the timeout is too high if a particular IP address is not found (i.e. the remote machine is not turned on). I also need to check that the remote listener is alive.
My solution to this was to write a small routine that "Pings" the remote object beforehand to see if it was alive. This "Ping" routine uses a s simple async TCP connection, so I can adjust the timeout:
Private HasResponded As Boolean<br />
Private Timeout As Integer = 100<br />
<br />
Private Sub TCPResponded(ByVal ar As System.IAsyncResult)<br />
HasResponded = True<br />
End Sub<br />
<br />
Public Function IsAlive(ByVal IPAddress As String) As Boolean<br />
Dim Conn As New AsyncCallback(AddressOf TCPResponded)<br />
Dim Tcp As New System.Net.Sockets.TcpClient()<br />
Dim MyTimeOut As Integer = Timeout<br />
HasResponded = False<br />
Tcp.BeginConnect(IPAddress, 9000, Conn, Nothing)<br />
<br />
While HasResponded = False And MyTimeOut > 0<br />
System.Threading.Thread.Sleep(10)<br />
MyTimeOut -= 1<br />
End While<br />
<br />
If Tcp.Connected Then<br />
Tcp.Close()<br />
Return True<br />
Else<br />
Tcp.Close()<br />
Return False<br />
End If<br />
End Function<br />
This class works fine when in the UI thread - it can tell me if a machine is alive or not within a second (I am only dealing with local ethernet, so one second is considered slow).
However, in my UI, I would like an icon to display the status of the remote machine. I thought I could write a simple background worker to call the above code. However, on the TCP.BeginConnect, I get the following error:
System.Net.Sockets.SocketException was unhandled by user code<br />
ErrorCode=10045<br />
Message="The attempted operation is not supported for the type of object referenced"<br />
Source="System"<br />
StackTrace:<br />
at System.Net.Sockets.Socket.DoMultipleAddressConnectCallback(Object result, MultipleAddressConnectAsyncResult context)<br />
at System.Net.Sockets.Socket.BeginConnect(String host, Int32 port, AsyncCallback requestCallback, Object state)<br />
at System.Net.Sockets.TcpClient.BeginConnect(String host, Int32 port, AsyncCallback requestCallback, Object state)<br />
<snip><br />
</snip>
Has anyone tried an Async connect within a background worker before, and got it working? I have tried googling this, but cant find anything that looks vaguely similar to my problem. As of yesterday, I had not even tried the beginconnect command, so dont really know all the details about it.
Thanks in advance.
Jason
modified on Thursday, March 13, 2008 12:59 PM
|
|
|
|
|
Hi..
After much googling and trials in getting ideas for coding for vista areo in vb.net .. i confused about a few things.
1. many articles indicate you have to be using vista with vb.net installed inorder to succeed at this..
at the moment my build is WIN XP with VB.NET ... can someone please shed some light.. am i way off..
basically the question is .. where can i start to find code or working sample for my app to cater to areo in VISTA and secondly do i need to have VISTA installed with and using VB.NET in a VISTA environment to do so..
kind regards
Robbo
|
|
|
|
|
Windows Aero is the graphical user interface and the default theme in most editions of Windows Vista. Aero also encompasses a set of user interface design guidelines for Microsoft Windows.
So, no. Aero is a user interface, not a set of APIs which you can program against.
Perhaps you were thinking of WPF?
|
|
|
|
|
Hi Colin..
so in short your saying my app wont be able to take advantage of aero interface unless i rewrite it using WPF is that right ???
I just thought there might be a away to add a few lines in my app to allow aero interace to work thats all..
please confirm this last thing and i thank you for your input
Regards
Robbo
|
|
|
|
|
vbbeg wrote: so in short your saying my app wont be able to take advantage of aero interface unless i rewrite it using WPF is that right ???
All apps will take advantage of the interface around the edges. The frames, the animations when minimizing/maximizing and so on. However, if you want the internals, your buttons, dropdowns, lists and so on to take advantage of the new features then you are going to have to change the presentation layer of your application to use WPF as it will use GDI currently.
|
|
|
|
|
SQLstr = "SELECT * FROM Slot where SectionID IN (SELECT SectionID from [Section] where Group='" & group & "')"<br />
con.Open()<br />
Dim DataAdapter As New OleDb.OleDbDataAdapter(SQLstr, con)<br />
DataAdapter.Fill(groupsection, "Slot")
the error is Syntax error. in query expression 'SectionID IN (SELECT SectionID from [Section] where Group='2')'.
in the statement DataAdapter.Fill(groupsection, "Slot")
but when i chang the coulm name with key value coulm it work
Group is not a key value
when i replace it with a key value(in db) it work
like
SQLstr = "SELECT * FROM Slot where SectionID IN (SELECT SectionID from [Section] where CourseID='" & course & " ')"
where CourseID is key value do you think that is the problem
pleeeeees i need help
|
|
|
|
|
Try this:
"SELECT * FROM Slot where SectionID IN (SELECT SectionID from [Section] where [Group]='" & group & "')"
Group is a keyword in SQL... You will need to add square brackets around it to get it to work.
|
|
|
|
|
|
Hello, first time asking a question here, so please be gentle
I'm filling a dataset and using OleDbDataAdapter.Update() to insert it into a DBF table using Jet. The update is running painfully slow and I've read up a bit on how to speed up and saw something about starting the transaction before running the update. Doesn't really seem to do much for me. I have a table write that goes on for 24 minutes. Any help would be appreciated.
Code snippit:
If Not cnDBConn.State = ConnectionState.Open Then
cnDBConn.Open()
End If
Dim transID As System.Data.OleDb.OleDbTransaction = cnDBConn.BeginTransaction()
cmInsert.Transaction = transID
daAdapter.InsertCommand = cmInsert
daAdapter.DeleteCommand = Nothing
daAdapter.UpdateCommand = Nothing
daAdapter.ContinueUpdateOnError = False
daAdapter.Update(dsOut, sCurrentTable)
|
|
|
|