Microsoft Access modWsh

From database24
Revision as of 15:47, 15 July 2010 by Dec (talk | contribs)
Jump to navigation Jump to search

getUserName

Function getUserName() As String
    Dim strResult As String
    
    Dim wshNet As WshNetwork
    
    Set wshNet = New WshNetwork
    strResult = wshNet.UserName
    
    getUserName = strResult
End Function

getComputerName

Function getComputerName() As String
    Dim strResult As String
    
    Dim wshNet As WshNetwork
    
    Set wshNet = New WshNetwork
    strResult = wshNet.ComputerName
    
    getComputerName = strResult
End Function

getUserSuffix

Public Function getUserSuffix() As String
    Dim strResult As String
    
    strResult = getUserName
    strResult = Replace(strResult, ".", "")
    strResult = Replace(strResult, ",", "")
    strResult = Replace(strResult, "-", "")
    strResult = Replace(strResult, " ", "")
    strResult = "_" & strResult
    
    getUserSuffix = strResult
End Function

getUserTempTable

Public Function getUserTempTable(strSource As String) As String
    Dim strResult As String
    
    Const strTablePrefix = "_tbl"
    
    strResult = strTablePrefix & Mid(strSource, 4) & getUserSuffix
    
    getUserTempTable = strResult
End Function