|
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"
|
|
|
|
|
|
I have never found a way to take advantage of thread names. Ideally one would give Thread instances a name, and be able to identify them by that name (rather than by a system-assigned number), however it does not work at all.
Furthermore, managed threads are virtual, there is no guaranteed one-to-one relationship with actual Windows threads, so you can't easily recognize your managed threads when looking at the output of tools such as Process Manager/TaskInfo
|
|
|
|
|
Hi all,
I have a vb.net application that uses dbase as the database.
When I run the application, if another application using the same dbase databse is open, the application crashes.
How to handle this case.
Any suggestions will be helpful.
Thanks in advance.
modified on Thursday, November 18, 2010 5:07 AM
|
|
|
|
|
A try/catch block around the code that gets a connection to the database?
|
|
|
|
|
Make sure that your app doesn't run when the other application is open. You can enumerate all the Windows on the desktop to check whether that's the case.
What version of dBase are you referring to? 4?
I are Troll
|
|
|
|
|
Thanks for the reply.
I'm using dbase IV.
|
|
|
|
|
Are you opening the dbase file in "Shared" mode ? Sounds like you are trying to access a resource with exclusive access and it cannot give it to you because someone else already has the resource.
I don't know the details of how to open a dbase file. I'm just talking theory here.
Good Luck.
|
|
|
|
|
Thanks for the reply.
The dbase file is not used in the shared mode.
Its on the server.
The same dbase file is used by another application and when that application is open, my application crashes.
|
|
|
|