|
Hi, I was wondering if anyone knew if there was a way to output bytes through a comm port in a HEX format rather than ASCII using the SerialPort control or any other method.
Thanks,
|
|
|
|
|
A serial port can transmit arbitrary byte values (i.e. binary data) as well as textual data.
The former is supported by methods such as SerialPort.Read() and Write(), the latter by ReadChar(), ReadLine() and more.
Not sure what you mean by "HEX format". Is it just binary data? use Read/Write! Is it text according to some specific format (such as Intel Hex, Motorola S-records, whatever), build your string and send it, or receive your string and decode it.
|
|
|
|
|
I have an application "app1" which create a UDP socket with port no. 6677.This app broadcast a data packet.
I hav another application "app2" which also create UDP socke which always listen 6677.Whenever the data packet comes it do certain operations.
Now problem is , when I run these to apps on different machines in the network, app2 detects the data packet.But when I run both the applications on the same machine,app2 never detects the data packet.
What may e the problem???
UDP socket related code in app2 is pasted here....
wsClientRecieve.RemotePort = 6677
wsClientRecieve.RemoteHost = "127.0.0.1"
wsClientRecieve.LocalPort = 6677
wsClientRecieve.Bind 6677
Thanks in adv..
|
|
|
|
|
I don't know the answer to your problem, however, I always start by asking myself: would I be the only one with such a problem? when not, I try google[^]. There sure are some interesting hits, such as this one[^]. Good hunting!
|
|
|
|
|
jainiraj wrote: two UDP socket on the same machine..
Damn, i thought this was the start of a Joke and was waiting for the punchline.
|
|
|
|
|
There once were two UDP sockets entering a bar. The bar tender says... I don't know any socket jokes, sorry.
|
|
|
|
|
The first one said:
- Hey, man, yesterday I asked Mary to marry me.
- And what did she say?
- Errr... I don't even know if she was listening...
Yep, this is UDP.
|
|
|
|
|
That is why SMS is more suited for the occasion I guess.
|
|
|
|
|
Ok, I have done something similar and got it working
I "think" the answer is that your localport on the "client" app should be 0 to allow it to use another port to connect from, I use .connect rather than .bind, I don't know enough to say whether this is because I am using vb6
basically only one process can create/bind port 6677 on a given PC and other processes have to connect to it. If you are indeed trying to create the socket in both processes the second create should fail
|
|
|
|
|
I have an excel file, I want to get the file name and store it in a cell.
How to do this?
Thanks in advance.
modified on Friday, November 19, 2010 4:48 AM
|
|
|
|
|
2 seconds of Googling found this[^]. You're going to kick yourself when you see how easy it is.
|
|
|
|
|
Thanks a lot.
The link was very useful.
|
|
|
|
|
Range("A1").value=ThisWorkbook.FullName
or
ActiveCell.value=ThisWorkbook.FullName
|
|
|
|
|
Thanks a lot for the code.
It gave me a part of the solution.
I would also like to know how to remove the extension of the Name.
code used:
Private Sub Workbook_Open()
Range("AK4").Value = ThisWorkbook.Name
End Sub
output:F28900035.xls
how to remove the extension from this Name.
Thanks in advance.
|
|
|
|
|
That's pretty simple too!
You just have to use the replace function.
For example
Dim str as String
str=ActiveCell.Value
Range("A2").Value=Replace(str,".xls","",1)
Cheers!
|
|
|
|
|
Thanks a lot for that piece of code.
It worked perfectly.
In the same way how to get the username/HostName of a system in a cell?
Thanks in advance.
|
|
|
|
|
Well using Google
i found the following code:
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Sub Get_User_Name()
Dim lpBuff As String * 25
Dim ret As Long, UserName As String
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
ActiveCell.Value=UserName
End Sub
Run the Get_User_Name macro.
I would suggest you to use google just like Dave said. its very helpful for developers!
Cheers!
|
|
|
|
|
Thanks a lot Tarun.
I will use google before getting into the forum.
Thanks once again.
|
|
|
|
|
vijay2482 wrote: I will use google before getting into the forum.
That's great.
thatraja |Chennai|India|
Brainbench certifications Down-votes are like kid's kisses don't reject it Do what you want quickly because the Doomsday on 2012
|
|
|
|
|
That's a bad solution to the problem as it relys on hard coded extensions to Excel files.
This code will NOT work in Excel 2007 as it's file extensions are long and varied.
A better solution would be to feed the filename to an instance of the FileSystemObject and its GetBaseName[^] method.
|
|
|
|
|
Thanks Dave,
I will use the GetBaseNAme function.
Seems to be interesting.
Thanks once again.
|
|
|
|
|
Thanks for correcting me Dave! i will use this method for sure!
|
|
|
|
|
Hi all,
Thanks to all who replied to my posts earlier.
I have another query that go as follows:
How to quit an application that is already open open the local machine from the application that I have done in vb.net.
ie: close other application that is open/running or close other application that is using the same database.
Thanks in advance.
|
|
|
|
|
I have used the below code to quit the other application that is running.
Catch exp As Exception
MsgBox("The Database is used by Ariane. Easy ECN will exit Ariane now.")
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("db2krun")
For Each p As Process In pProcess
p.Kill()
Next
|
|
|
|
|
HI,
How to check how many thread currently running??
Any possibility to get the solution ??
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|