VB Script

37K

Solutions

20K

Contributors

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

Share tech news, updates, or what's on your mind.

Sign up to Post

I want to VBA code to encrypt the password/serial number saved in a column with a specific number.
for example if password is abc I will add a number to it I want to save it as abc+that number not the real password.
When I click on decrypt I want a popup to enter the number I added while saving.
Finally remove the number should give the correct passwords
0
Become a Microsoft Certified Solutions Expert
LVL 13
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Trying to convert VB code to C#. Never really worked with C#. It's just taking a pulling the information from a JSON file so I can upload to a database. Have in VB but want to switch to C#. Below is the VB code:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim filePath As String =
            IO.Path.Combine(_desktop, "Upload.txt")

        Dim data As Upload =
            JsonConvert.DeserializeObject(Of Upload)(IO.File.ReadAllText(filePath))
End Sub
Public Class Upload
        Public Property Primaryimage() As WebImage
        Public Property Secondaryimages() As List(Of WebImage)
        Public Property Notes() As List(Of String)
        Public Property SafetyPrecautions() As SafetyPrecautions
End Class
Class WebImage
        Public Property Alt() As String
        Public Property Src() As String
End Class
Public Class SafetyPrecautions
        Public Property Warnings() As List(Of String)
End Class

Open in new window


Might be all wrong but this is what I have for C#

public partial class frmProcessJsonFile : Form
    {
        private string _desktop;
        public frmProcessJsonFile()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string filePath = System.IO.Path.Combine(_desktop, "Upload.txt");

            Upload data = JsonConvert.DeserializeObject<Upload>(System.IO.File.ReadAllText(filePath));
                  }

        public class Upload
            {
             public IEnumerable<WebImage> Primaryimage { get; set; }
              
    }

        class WebImage
        {
            public string Alt { get; set; }
            public string Src { get; set; }
        }
    }

Open in new window


Any help would be appreciated.
0
Looking to count the number of SQL records until a certain value in one of the table columns is reached. Using Asp /VBscript. Not sure how to formulate the query.

What I'd like is to organise the results by the column "points" in descending order, grouped by the "city_id". I then need the number of records counted until a specific "member_id" is matched. Some "points" values could also be the same, which can cause an incorrect count. Similar points values should be ignored.

the db table is named "rankings" and is structured like this:

id  |  member_id  |  city_id  |  points
1   |      1      |   12500   |    2
3   |      2      |   12500   |    5
4   |     34     |     800     |    1
5   |     14     |   12500   |    14
6   |      6      |     600     |    12
7   |     11     |   12500   |    11
8   |     12     |   12500   |    5

For example, if I want to find the ranking for member_id "2", who happens to belong to city_id "12500", the correct final returned value from should be 3. This is because member_id "2" has the third highest points value in city_id "12500", even after taking into account the tie in points with member_id "12".

This below is all I can think of as I'm not a pro by any means and I know it's missing a lot!


member_id = 2
city_id = 12500
SELECT Count() as city_ranking FROM (SELECT * from rankings WHERE city_id='"&city_id&"' AND member_id <> '"&member_id&"' ORDER BY points DESC)
0
NOTE : This is a follow up question from : https://www.experts-exchange.com/questions/29139469/Macro-to-convert-data-in-txt-into-excel-format.html?headerLink=workspace_answered_questions

Instead of having 1 set of data, i have multiple sets basically the structure is repeated several times.

Currently i am pasting the text file individually by transferring the multiples into 1 .txt file each so that the macro can read all the txt files and convert them to data in excel.
How to have a macro to also read text files with several repeated structure ?

See attached file. In this file, you can see that the structure appear 3 times.
MACRO_MULTIPLES.xlsx
0
I want to continuously searching all files base on the code below. The code below will stop once it found the item. How to improve the code to  let the searching search the entire drive. Thank you!

Option Explicit
Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal _
InputPathName As String, ByVal OutputPathBuffer As String) As Long
 
Private Const MAX_PATH = 260


Private Sub Command2_Click()
    Dim strPadPath As String
    Dim lngAmIHere As Long
    'create a buffer string
    strPadPath = String(MAX_PATH, 0)
    'Typically, lngAmIHere will return 1 if successfull, 0 if not
    lngAmIHere = SearchTreeForFile("C:\Program Files\WebPrinterActivator\", "WebPrint.exe", strPadPath)
    'MsgBox Trim(strPadPath)
    If lngAmIHere <> 0 Then
        'MsgBox "Located file at " + Left$(strPadPath, InStr(1, strPadPath, Chr$(0)) - 1)
        MsgBox "Found!"
    Else
        MsgBox "Not found!"
    End If
End Sub
0
See environment below

Need VBA running in either Access (preferred) or excel which will add/delete a user to a sharepoint group and also list all members of a group into a table or excel sheet.

I've tried the OData approach for getting all users but unsure how to get it working in Access.

Environment: SharePoint 2013 - onprem, full control only (no SCA), and no farm access (no powershell).

VBA examples sought - not C##, powershell, ...
0
Hello,

I'm looking for a macro that will find the last row of data and then drag a formula from a specific cell down to that last row.  In the attached example, the formula is in C2.  I'd like the macro to identify row 6 as the last row containing data and then drag the formula from C2:C6.  The end result would show cells C3 and C4 as 'IV'.

Thanks,
0
I created the following code to open an Excel file and select a particular sheet based on the Property Code that was previously copied into the clipboard.  HOWEVER, it stay minimized and blinking on my bottom toolbar.  I googled and try adding the 3 lines starting with Set MyObj=CreateObject("WScript.Shell, but that had no effect.  Any suggestions to bring it to the forefront and maximized.  Note, I start the whole process from a button in a Filemaker dbase layout so Filemaker is in the forefront and unfortunately remains there.  Thank you.

Dim xlApp, xlWb

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWb = xlApp.Workbooks.Open("N:\EXCEL\Files\SHARED TOOLS\Sales Reports\SALES REPORTS.xlsm")

xlApp.Run "'" & xlWb.Name & "'!SelectSheet"

Set MyObj=CreateObject("WScript.Shell")
myobj.appactivate "Microsoft Excel"
set myobj = nothing

'if the macro takes arguments, use:
'xlApp.Run "'" & xlWb.Name & "'!NameOfMacro", "Arg1", "Arg2", "Arg3"


'xlWb.Close True
Set xlWb = Nothing
'xlApp.Quit
Set xlApp = Nothing
0
I am using Treeview in Asp.net with VB, I am using Asp.net tabs and in one of tab, treeview is binded, When I select treeview node item then it gets focus and scrolled so it's visible in treeview, When I change tab and come back on treeview tab then last selected node remain selected but focus don't come, is there anyone to find selected node and set focus into that? How to get focus on Treeview node. Please help.
0
From the reading pane of Outlook, I would like to quickly copy the contents (body and header) of a highlighted email messages to be able to paste into a work order system.

Is there a way to do this with Quick Steps or would I need a macro?

I can semi-manually do this by hitting Reply then CTRL+A and erasing my signature at the top of the reply, but it gets tedious.
If there is a way to reply without Signature when using the macro/quick step (without changing my signature preferences), that would be ideal.

Thanks!
0
JavaScript Best Practices
LVL 13
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

I have 2 workbooks open that I want to compare using view side by side function and also synchroinous syncing .

Is there anyway that I can create a macro so that it looks down the two workbooks  comparing data and if missing from 1st sheet it highlight it.

Looking  at the attachment I want to look in the 1st sheet on the tab selected in columns  B/C/D/E  and check to see if in 2nd sheet in columns A/B/C/D . If not in 2nd sheet can I highlight it on 1st sheet selected tab or put onto a new sheet.

I need it to look all the way down looking for a match in 2nd sheet in columns B/C/D/E.

Is this possible?
screenshot.jpg
0
I have a workbook that I have a tab  in it called "NEW REC" and I have another workbook that has data in it on sheet 1 that  I need to compare.

Data in sheet called "NEW REC" has data in columns A,B,C,D  and this also the case in other workbook as in data in columns A-D.

Im trying to make a compare macro that I can save to a personal macro  so I can use it in different workbooks. I think thats correct?

I will always have the workbook with the tab NEW REC open and I donno if I can set it up so it asks me where to look for other sheet to open to be able to compare.
If I can I then need it to look down the sheet called "NEW REC" and compare against data in new workbook Ive opened.

If there are matches in rows down worksheet  ive opened and also in NEW REC tab that are exactly the same I need them ignored in the  tab "NEW REC" and if dont match  highlight them in NEW REC tab.  

What I mean by this is lets say row 5 columns A-D  match with exactly the same data in workbook I opened in row 99 columns A-D then thats a match and ignore but as stated if nothing compares then need highlighted in new rec tab.


I had this macro but but it compares 2 sheets in the same workbook and as stated im trying to get it to ask me where I want to look to compare

Sub CompareData()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    Dim Val As String, ws1 As Worksheet, ws2 As Worksheet, i As Long, v1, v2, RngList As Object
    Set ws1 = Sheets("Sheet1")
 

Open in new window

0
Hi im no expert in formulas and was given this by a work colleague who since left and thus why asking the experts :-)

Ive got the formula of

=INDEX($BA$1:$CT$1,ROWS($A$6:A28))&" "&INDEX($BA$2:$CT$2,ROWS($A$6:A28))

which I believe takes the data from cells BA1-CT1 and also from BA2 to CT2 and works it way down the rows on a page where I paste it. What Im trying to do is get the data starting from BA3 and copy all the way down the sheet as It is with other formula. The only thing is it will always be row 3 and just the one row. or can I add it to this formula?

Any Ideas?

Thanks
0
Hi I have asp.net vb web application , I want to deploy that to Google Clouds Platform, I am using Oracle database in that Web Application, I am confused which method to use, Either Google App Engine .NET Flexible Or Compute Engine or something else
0
I'm using the following code in my application  to authenticate credentials against active directory.  This works on most servers, but on one I need to configure now, I get the error:
"A more secure authentication method is required for this server."
How do I need to revise the code to make it work with a secure connection?

strTest = agencyDomainName & "\" & strUsername
agencyLAPDstring = "LDAP://JICL.Azure,DC=org"

Set objLDAP = GetObject("LDAP:")

Set objDomain = objLDAP.OpenDSObject(agencyLAPDstring, strTest, strPassword, 0)
0
require to setup robo copy to copy without overwrite option . Copy files and folder. Copy files according to date . for an example copy files from 1st April 2012 to 31 june 2012.
1
Hi,

I have a production machine (Windows 2012r2) that was create by someone else and it was create with dynamic disk and checkpoint (created at beginning). I don't know why he does that but I have some disk performance issue with it. I'm not an expert so I tried to correct that but I made some error. First I shutdown the vm and copy (with windows explorer) the vm folder to an external disk because I don't have any disk that have enough space on server. The dynamic disk have 600gb configure and use 10gb on disk. The checkpoint file have 450gb. Now I made a big mistake. I deleted the checkpoint and lost the 450gb file. Now I'm copying back the folder I copied before.

My first question is, I saw I must use export but is it possible to import the folder I copied before or I'm in big trouble?

With powershell or other script, Is it possible to apply the checkpoint file to the vhdx file and after convert it to fixed size?

Thank you!

Dan
0
In UFT is there a way to copy contents of a GridView to a Datatable?

Looking at using the .SelectAll, but not sure how to get them into a given Datatable.  Any ideas?

SAPGuiSession("Session").SAPGuiWindow("List of Sales").SAPGuiGrid("GridViewCtrl").SelectAll
0
Hi All

The below script deletes all contact objects in outlook where the mileage attribute = 500. Is there any way to add a condition to the script to prevent the contact from being deleted if it has any additional email addresses configured e.g. do not delete if a contact where mileage = 500 but has either email 2 or email 3 configured

Dim objOutlook
Dim objNamespace
Dim objFolder
Dim objItem
Dim objRecord

Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(10)
Set objItem = objFolder.Items
Set objRecord = objItem.Find("[Mileage] = ""500""")

While Not objRecord Is Nothing
	
	If objRecord.Body = "" Then objRecord.Delete
	Set objRecord = objItem.FindNext

Wend

Set objRecord = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNamespace = Nothing
Set objOutlook = Nothing

Open in new window

C--Users-harrison.brooks-Desktop-Pro.PNG
0
Why Diversity in Tech Matters
LVL 13
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

I had this question after viewing Dependent Drop List - SQL and VBS.


I'd like to modify the below code to filter on any database field. So, I have a table with addresses - I want to filter zip codes, and see the cities in that zip code. Thanks!



<html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
  APPLICATIONNAME="My HTML application"
  ID="MyHTMLapplication"
  VERSION="1.0"/>
</head>

<script language="VBScript">

Option Explicit

Sub Window_OnLoad

' Populate year field with last 10 years in reverse order
AddOption "Field1","Select Year",""
Dim YYYY
For YYYY=Year(Date) To Year(Date)-10 Step -1
	AddOption "Field1",CStr(YYYY),CStr(YYYY)
Next

AddOption "Field2","Select Year first",""

End Sub

Sub ReadSQLData(WhichYear)
  ' Read information from SQL server and put into Field1 and Field2


  Dim oDb : Set oDb = CreateObject("ADODB.Connection")
  oDb.Open "Provider=SQLOLEDB;Trusted_Connection=Yes;Server=myServer;Database=myDatabase;"
  Dim sQL : sQL     = "SELECT Code_Number FROM [CODE] WHERE Year='" & Whichyear & "'"
  Dim oRS : Set oRS = oDb.Execute(sQL)

  Do Until oRS.EOF
  AddOption "Field2",oRS.Fields("Code_Number").Value,oRS.Fields("Code_Number").Value
      oRS.MoveNext
  Loop

End Sub

Sub AddOption(fieldname,SetText,SetValue)
' Pass in the control ID and the text and values to add to it
	  Dim oDD, oOpt
	  Set oDD = 

Open in new window

0
Good Afternoon,

I am looking for a simple tidy up script that would search a particular CSV file for email addresses from a list, if any matches found from the list, replace them with a new entry from a list.

Example below

Searching for

site1@company.co.uk - Replace with site1@company.com
1
Hi all

Is it possible with vb script to achieve the following:

if I have two sub folders in outlook for contacts e.g. ‘sub folder 1’ and ‘sub folder 2’. If there is a duplicate contact found in each folder (matched by email address) is there a way to copy one particular attribute from one to the other. The idea being that we want to collapse ‘sub folder 1’ But ensure we copy all information in the notes field to the same contact found in ‘sub folder 2’ before we delete ‘sub folder 1’.
0
Event on cell Changes in Excel.

I have a office addin where i react to a cell change event, working fine.

Sometimes the change will be from userinput, sometimes i will modify a cell through a automated call to server.

In both cases the veent fires: I need to deactivate this when my ADDIN modifies th cells, otherwise i will be runningn in circles.

Does anybody have a basic idea on how top solve this, besides writing the server modifications to an array, and parsing it with every event.

thanxs
0
Private WithEvents MyExplorers As Outlook.Explorers
' How do I assign each MyExplorers instance with an ID, say oEXP1, oEXP2, oEXP3, ..., oEXPN?

Private WithEvents MyItem As Outlook.Items

Private Sub MyItem_ItemAdd(ByVal Item As Object)
    ' this event runs only when an explorer instance oExp1 exists  (active or not active)
End Sub

Private Sub Macro1()
    ' this macro runs only when an explorer instance oEXP2 exists
End Sub

Private Sub Macro2()
    ' this macro runs only when an explorer instasnce oEXP3 exists
End Sub

Open in new window


I believe the above VB code is pretty self-explanatory, but how do I identify/detect each outlook explorer instances that is run, preferably by some unique ID?
0
Hi all.

I have a VB.net chart that displays sales stages and the count for each sales stage. I want to be able to allow the end user to double click the X-axis label, which is the sales stage, and save that value in a variable. Unfortunately, I haven't been able to do so. Below is some of the code, I'm trying to show it in a messagebox for now, I've been playing with but unable to get it to work. I basically want to get the axislabel when it's double clicked.

Private Sub Chart1_MouseUp(sender As Object, e As MouseEventArgs) Handles Chart1.MouseUp
 Dim HTR As HitTestResult
       HTR = Chart1.HitTest(e.X, e.Y)
Dim h As HitTestResult = Chart1.HitTest(e.X, e.Y)
If h.ChartElementType = ChartElementType.AxisLabels Then
Dim dp As DataPoint = Chart1.Series("Stages").Points(h.PointIndex)
MsgBox(dp.AxisLabel)
End If
 End Sub

Open in new window


I was able to get this to work by clicking the datapointlabel instead of the axislabel, but ultimately I would like it to work for the axislabel. See code below:

Private Sub Chart1_MouseUp(sender As Object, e As MouseEventArgs) Handles Chart1.MouseUp
Dim SelectDataPoint As DataPoint
Dim h As HitTestResult = Chart1.HitTest(e.X, e.Y)
If h.ChartElementType = ChartElementType.DataPointLabel Then
SelectDataPoint = CType(h.Object, DataPoint)
            MsgBox(SelectDataPoint.AxisLabel.ToString)
End If
 End Sub

Open in new window

0

VB Script

37K

Solutions

20K

Contributors

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.