473,382 Members | 1,225 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Finding the current computer name in VB?

Hello,

Is there a way to find the current machine name using VB? I'm trying to log
user activity, but I'd also like to log the location as well i.e. if errors
occur, then I can get an idea what machine the user was on when the
exception was thrown in case that has anything to do with the issue.

Any help would be great! Thanks!
Nov 13 '05 #1
2 4465
This works fine for me http://www.mvps.org/access/api/api0009.htm

"Jozef" <SP**********@telus.net> wrote in message
news:ZO%Se.94070$Hk.62070@pd7tw1no...
Hello,

Is there a way to find the current machine name using VB? I'm trying to
log user activity, but I'd also like to log the location as well i.e. if
errors occur, then I can get an idea what machine the user was on when the
exception was thrown in case that has anything to do with the issue.

Any help would be great! Thanks!

Nov 13 '05 #2
"Jozef" <SP**********@telus.net> wrote in message
news:ZO%Se.94070$Hk.62070@pd7tw1no...
Hello,

Is there a way to find the current machine name using VB? I'm trying to log user activity, but I'd also like to log the location as well i.e. if errors occur, then I can get an idea what machine the user was on when the
exception was thrown in case that has anything to do with the issue.

Any help would be great! Thanks!

Paste the following code into a new module:

'--------------------< begin code >--------------------
Private Declare Function GetComputerNameA Lib "kernel32" _
(ByVal lpBuffer As String, nSize As Long) As Long

Public Function CurrentMachineName() As String
Dim lSize As Long
Dim sBuffer As String
sBuffer = Space$(16)
lSize = Len(sBuffer)

If GetComputerNameA(sBuffer, lSize) Then
CurrentMachineName = Left$(sBuffer, lSize)
End If

End Function

'---------------------< end code >---------------------

Now you can retrieve the current machine name with CurrentMachineName().
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Victor Engmark | last post by:
When looking for a method to fetch unique elements and counting the number of occurences of each of them, I found quite a lot of gross examples of complex XSL. But after realizing the subtle...
2
by: Ginu | last post by:
Hi, the task is to identify semantically identical elements where some additional attributes do not match. The XSL-transformation should find a node NAME which @id attribute matches to another...
4
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could...
7
by: Ewart MacLucas | last post by:
Does anybody know how to find the workgroup name (or domainname) of the local PC. Is there a framework class for it? (preferably a solution not involving active directory calls) Thanks,...
7
by: Jason Reichenbach | last post by:
I've GOT to be missing something painfully obvious, here... I need to programmatically get the full human name of the current user on a local system, the same system upon which the app is...
9
by: dave m | last post by:
I need to be able to retrieve a unique ID from a users PC. I needs to be something a user could not easily change, like the computer name. Could someone point me in the right direction to find ...
3
by: Rico | last post by:
Hello, I have a generic process that logs errors from different sources. When I call this code, I'd like to also submit the name of the function or sub that is raising the error without having...
3
nomad
by: nomad | last post by:
When I run choice == 2 I'm suppose to a an out.println back finding a product. but I get Null for all the values. Can someone help me with this. class Computer_listing { private String id; ...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.