Visual Basic ClassicSponsored by Jamf Now

163K

Solutions

58K

Contributors

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

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

Sign up to Post

I am trying to trigger a macro AFTER an email is sent in Outlook. The purpose of the macro is to pop up with a message to ask if needs saving, and if so, save it to a specific folder in Windows File Explorer.

I saw a message in this forum regarding the same: [url="https://www.experts-exchange.com/questions/24816434/Run-macro-after-mail-is-sent.html"]
I copied the code into "ThisOutlookSession". it triggers for the 1st email sent out, but not for the subsequent ones.

Can somebody help me out here?

THanks

WS
0
Ultimate Tool Kit for Technology Solution Provider
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Is the latest version of Visual Basic part of Visual Studio 2017?  I really only need the latest version of Visual Basic for Winows 10.  That's all I really need.
0
Hi Experts,

I'm looking to modify the below to be an update instead of a select.
however not sure where do I put in the body param as specified below
https://howto.caspio.com/web-services-api/rest-api/older-rest-api-versions/table-operations/

Function GetDataFromCASPIO1()
    Dim objHTTP As New WinHttp.WinHttpRequest
    Dim docXML As MSXML2.DOMDocument
    Dim ResponseText As String
    Dim curNode As IXMLDOMNode
    Dim oNodeList As IXMLDOMSelection
    Dim s As String

    Set docXML = New MSXML2.DOMDocument

    Set objHTTP = New WinHttp.WinHttpRequest
    URL = "https://MyAccount.caspio.com/oauth/token"
    
    objHTTP.Open "POST", URL, False
    objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    objHTTP.Send 
    ResponseText = Right(objHTTP.ResponseText, Len(objHTTP.ResponseText) - 17)
    access_token = Left(ResponseText, InStr(ResponseText, """") - 1)
    'Debug.Print access_token


    Set objHTTP = New WinHttp.WinHttpRequest

    URL = "https://MyAccount.caspio.com/rest/v1/tables/Skilled_Nursing_Visit_Note/rows?q={""limit"":10000,""where"":""visit_date>=GetDate()-7""}"

    '''objHTTP.Open "GET", URL, False
    objHTTP.Open "Put", URL, False
    objHTTP.SetRequestHeader "Accept", "application/xml"
    objHTTP.SetRequestHeader "Content-Type", "application/json"
    objHTTP.SetRequestHeader "Authorization", "Bearer " + access_token


    objHTTP.Send
    'Debug.Print objHTTP.Status
    'Debug.Print objHTTP.ResponseText
  

Open in new window

0
Hi Experts,

I have the following lines of code retrieving all records from a particular table.
Would like to build a SQL string that will insert them into a local Access table.

Can someone help me accomplish that?

PS. there are different datatypes, so perhaps its also possible to inspect the Access datatype for that field before adding it to the SQL string..

    strXPathQuery = "Caspio/Row"
    Set oNodeList = docXML.selectNodes(strXPathQuery)
    For n = 0 To (oNodeList.length - 1)
        Set curNode = oNodeList.Item(n)

        For m = 0 To (oNodeList.Item(n).childNodes.length - 1)
            Debug.Print oNodeList.Item(n).childNodes(m).nodeName + " => " + oNodeList.Item(n).childNodes(m).Text

        Next
    Next

Open in new window


Thanks in advance.
0
I have a folder with sub folders of which are  password protected/7 zipped   and unprotected.

When people click on the 7zip folder it asks for the password of which they will be supplied and has a self extract command so it will unzip as a unprotected  sub folder in the same folder as the protected ones .

I.E C:\DOWNLOADS has sub folders that are 7 zipped and also when unzipped it has the same folder name unzipped,

What im trying to do is to get a command or something for the unzipped folders( file folder)  to be deleted every night at 23.50 hrs but the 7zip files (applicaions) to remain there for 30 days after the day it was created so if I had a 7zip file modified 01/06/18 I need that permanently deleting on 30/06/18  and if I have a file folder in the folder I need that deleted at 23.50 hrs that night.

Hope that makes sense and can anyone advise on best way of moving forward.
0
Hi Experts,

I have 4 integer fields as follows
Shift_From_Hour
Shift_From_Minute
Shift_To_Hour
Shift_To_Minute

and use the following to calculate the time difference between both shifts.
Duration: Abs(DateDiff("n",TimeSerial(Nz([Shift_From_Hour]),Nz([Shift_From_Minute]),0),TimeSerial(Nz([Shift_To_Hour]),Nz([Shift_To_Minute]),0)))

Open in new window

However users claim its not always accurate, if Shift_From_Hour is after 8PM (20), it will yield wrong results..
What is the right way to calculate this?
0
sample.phpRunning, or utilising PHP scripts from VB6.

I have a large VB6 application which I developed over many years, and has been operating for many many years now.

My software has no issue consuming Web Services using MSXML2 to call various XML and JSON feeds.

However, in this instance, I need to communicate back and forward, and I'm slightly stumped as to best way to move forward. I've been presented with a PHP code which (a) has a login function to get a authorisation code, and (b) using that authorisation code, I need to send variables to submit a transaction, which supposedly will return a response.

I've attached the basic (modified) PHP script, and I'm looking for "nudges" in the right direction. The variables needed to pass to the login function, and order function are contained in my vb6 software.

Much Appreciated any assistance.
0
I wonder if I can get some help migrating a VB6 project with Crystal 8.0/8.5?  These are windows' 10 PCs.

The reports are working in the development machine but the production machine keeps having problems with an 20599 error.

I checked the ODBC 32bit connection and that is connecting fine.
0
Hi Experts,

We have the following function that used to work for years, now suddenly its starting to cause problems.

Public Sub SendEmail(Optional sTo As String = "", Optional sFrom As String = "", Optional sSubject As String = "", Optional sBody As String = "")
    Dim imsg As Object
    Dim iconf As Object
    Dim flds As Object
    Dim schema As String

    Set imsg = CreateObject("CDO.Message")
    Set iconf = CreateObject("CDO.Configuration")
    Set flds = iconf.Fields

    ' send one copy with SMTP server (with autentication)
    schema = "http://schemas.microsoft.com/cdo/configuration/"
    flds.Item(schema & "sendusing") = cdoSendUsingPort
    flds.Item(schema & "smtpserver") = "smtpout.secureserver.net."
    flds.Item(schema & "smtpserverport") = 3535
    flds.Item(schema & "smtpauthenticate") = cdoBasic

    flds.Item(schema & "sendusername") = "MyEmail@MyDomain.net"
    flds.Item(schema & "sendpassword") = "MyPWD"
    flds.Item(schema & "smtpusessl") = False
    flds.Update

    With imsg
        .To = sTo
        .From = sFrom
        .Subject = sSubject
        .HTMLBody = sBody
       '.Sender = "Sender"
        '.Organization = "My Company"
        '.ReplyTo = "address@mycompany.com"
        Set .Configuration = iconf
        .send
    End With

    Set iconf = Nothing
    Set imsg = Nothing
    Set flds = Nothing
End Sub

Open in new window


See attached error message.
Untitled.png
0
I have a Class Questions which includes the following properties:
1) The Question - String
2) The QuestCode - String
3) PAQuest - Boolean
4) QuestAns - Boolean
5) The QuestID - Long

I instance an object
     Set oQst = New clsQuestions
I load the object from an SQL datatable
I then add the object into a dictionary (dicQuestions)
    dicQuestions.Add CStr(oQst.QuestID), oQst

Based on the value of PAQuest  - if true I also add the object into another dictionary (dicPAQuestions)
    If oQst.PAQuest Then
          dicPAQuestions.Add CStr(oQst.QuestID), oQst
    End If

After loading all the questions, I stop (breakpoint) and run the following
    Debug.Print "Main: " & dicQuestions.Item("3217").Question
    Debug.Print "Main: " & dicQuestions.Item("3217").QuestAns

    Debug.Print "PA: " & dicPAQuestions.Item("3217").Question
    Debug.Print "PA: " & dicPAQuestions.Item("3217").QuestAns

    dicQuestions.Item("3217").QuestAns = True

    Debug.Print "Main: " & dicQuestions.Item("3217").Question
    Debug.Print "Main: " & dicQuestions.Item("3217").QuestAns

    Debug.Print "PA: " & dicPAQuestions.Item("3217").Question
    Debug.Print "PA: " & dicPAQuestions.Item("3217").QuestAns

My results are:
Main: Question Number 1
Main: False
PA: Question Number 1
PA: False

' This is where I set the QuestAns in the dicQuestions dictionary to TRUE

Main: Question Number 1
Main: True
PA: Question Number 1
PA: True <<<===== This is the problem
0
Cloud Class® Course: Python 3 Fundamentals
LVL 12
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Hi Experts,

I would like to have a function that merges two records as follows.

we want all data of both records to be saved under one record.

function should have two params EmpID1 and EmpID2.

Goal = all data should be consolidated into EmpID1.

Lets say we have table named Employeestbl with dozens of fields of all types, some are nvarchar, some are dates etc..

function should loop thru all table fields and will check if fieldtype is nvarchar or int or anything but datetime, then if one record has field null and the other one has data then update (EmpID1) with that data.

If datatype is date then in addition to the above, if both has data should check which has later date and update to that.

How is that possible?

Thanks in advance.
0
Hi All,
I'm working with VB6.  Project (for now) must remain VB6.
I have a class called clsQuestions.  Objects of this class are created and populated by reading from an SQL datatable.
Each of the objects is added to a dictionary (dicQuestions).
A subset of the questions are also added to another dictionary (dicPAQuestions) based on a flag in each record.
dicQuestions are used in one area of my program, and dicPAQuestions is used in another.
The class has a property - QuestAnswered which gets set when an answer to the question is selected (by the operator).
I need to keep track of how many of the questions from each dictionary have been answered - iAnsCount and iPAAnsCount.
Since VB6 can't "Share" methods, what would be the best way to accomplish this feat? (I know - switch to VB.Net or C# - but not possible).
Thanks for any help
Below is the Question class

Option Explicit

Private mvarQuestID As Long 'local copy
Private mvarQuestion As String 'local copy
Private mvarQuestCode As String 'local copy
Private mvarPAQuestion As Boolean 'local copy
Private mvardicAnswers As Dictionary 'local copy
Private mvarQuestAnswered As Boolean        ' Has a question been answered?

Public Property Set dicAnswers(ByVal vData As Dictionary)
    Set mvardicAnswers = vData
End Property

Public Property Get dicAnswers() As Dictionary
    Set dicAnswers = mvardicAnswers
End Property

Public Property Let PAQuestion(ByVal vData As Boolean)
    mvarPAQuestion = vData
End Property

Open in new window

0
I have an Access 2010 database and a command button with the following code:

  Dim stDocName As String
  Dim stLinkCriteria As String
  Dim strFindEval As String
  Dim strFindStaff As String
  Dim Staff As String
  Dim Evaluator As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim UserName As String
    UserName = Environ("USERNAME")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    If UserName = "ABC" Or UserName = "DEF" Then
    strFindEval = InputBox("Enter Evaluator's Initials", Evaluator)
    strFindStaff = InputBox("Enter Staff Member's Initials", "Staff Member")
        stLinkCriteria = "[Staff]=" & "'" & strFindStaff & "'" _
        & " AND " _
        & "[Evaluator]=" & "'" & strFindEval & "'"
            GoTo Select_Form
        End If
    strFindEval = UserName
    strFindStaff = InputBox("Enter Staff Member's Initials")
        stLinkCriteria = "[Staff]=" & "'" & strFindStaff & "'" _
        & " AND " _
        & "[Evaluator]=" & "'" & strFindEval & "'"

Select_Form:
' Accounting
    If strFindStaff = "GAS" Or strFindStaff = "RJL" Then
        stDocName = "frmEvalStaffAcctDone"
            Else
        stDocName = "frmEvalStaffDone"
    End If


I need the code to use the data entered in the strFindStaff prompt and then see if this user is a member of the ACCOUNTING group.

I'm hoping to replace the following so that it looks to see if "GAS" OR "RJL" are members of a …
0
Getting an error message with all excel files that contain macros - Windows Malware protection (see attached note that pops-up)

Windows blue pop-up says that it detected malware and windows defender is removing it and then when I open the file the macros are gone!

Worked fine a week ago

Verified that  macros are enabled in the Excel trust center
16-17-zip.xlsm
Capture.JPG
16-17-zip.xlsm
0
Hello all;

OK, I need to count some numbers, and if the number matches, then assign that number to the folder.

This is the Image folders. (yes, the X is in the name of the folders)
000XXXXX
001XXXXX
002XXXXX
003XXXXX
004XXXXX
005XXXXX
006XXXXX
007XXXXX
008XXXXX
009XXXXX
01XXXXXX
02XXXXXX
03XXXXXX
04XXXXXX
05XXXXXX
06XXXXXX
07XXXXXX
08XXXXXX
09XXXXXX
1XXXXXXX
2XXXXXXX
3XXXXXXX
4XXXXXXX
5XXXXXXX
6XXXXXXX
7XXXXXXX
9XXXXXXX

Open in new window


These are some sample of the images, corresponding with their folder names.
001XXXXX
00100000.jpg
00101934.jpg
00103153.jpg
00199013.jpg

Open in new window

002XXXXX
00202549.jpg
00287068.jpg
00298070.jpg

Open in new window

09XXXXXX
09970234.jpg
09971079.jpg
09971795.jpg

Open in new window

1XXXXXXX
13523105.jpg
14002020.jpg
14050044.jpg
14050054.jpg

Open in new window


This will get the number of leading 0s.
<%strCLID = "00102348"%>
<%getCount = len(strCLID)-len(clng(strCLID)) &"-"& strCLID%>
getCount = 2

Open in new window


And for the long number: 14050054
The result is
-1

So, it would need to be something like this.

<%
if strNum="13523105" then
getFolder = "1XXXXXXX"
elseif strNum="03523105 then
getFolder = "03XXXXXX"
if strNum="93523105" then
getFolder = "9XXXXXXX"
if strNum="00523105" then
getFolder = "00XXXXXX"
elseif ......etc...
%>
This will be used in the image link
<img src="graph/item/<%=getFoldre%>/<%=getImage%>" />

Open in new window


Any ideas on this one?

Thanks, All
Carrzkiss
0
I would not even begin to tell you why I need this, but does anyone know the Hexadecimal code for a zero-width joiner or a zero-width non-joiner? [/b]
1
notepad++ how to color a word.  say i have word called happy. I want to color it as yellow brush show that it is more distinguishable.
how to do it.
Also how to do that in word pad as well

Please advise
0
I have a set of code that creates an array and populates it with the distance between a set of two coordinates, however using this function it gives a run-time error, invalid procedure or argument. The weird thing is that the code only slips on a select few data points and when these points are deleted the code runs until it hits another set of data that it doesn't like and gives the same message once again.
Option Explicit

Sub test()

    Dim sheetSource As Worksheet
    Dim sheetResults As Worksheet

    Dim intPos As Long
    Dim intMax As Long

    Dim i As Long
    Dim j As Long
    Dim strID As String

    Dim dblDistance As Double
    Dim dblTemp As Double

    Dim Lat1 As Double
    Dim Lat2 As Double
    Dim Long1 As Double
    Dim Long2 As Double

    Const PI As Double = 3.14159265358979

    Set sheetSource = ThisWorkbook.Sheets("Sheet1")
    Set sheetResults = ThisWorkbook.Sheets("Sheet2")

    intPos = 1

    ' 1 Build the matrix
    For i = 2 To sheetSource.Rows.Count

        strID = Trim(sheetSource.Cells(i, 1))

        If strID = "" Then Exit For

        intPos = intPos + 1

        sheetResults.Cells(intPos, 1) = strID
        sheetResults.Cells(1, intPos) = strID

    Next i

    intMax = intPos


    If intMax = 1 Then Exit Sub ' no data


    ' 2 : compute matrix
    For i = 2 To intMax 'looping on lines

        Lat1 = sheetSource.Cells(i, 2)
        Long1 = sheetSource.Cells(i, 3)

        For j = 2 To intMax 'looping on columns

           

Open in new window

0
How can I combine these two sql queries so that they both show up on the datagrid in vb6?  I want the first query to be combined with the bottom code.


    esql = "select H.Agency,H.RegID,R.LastName,R.FirstName, H.ActivityID,A.ActivityName,H.Narrative, H.ActivityDate, H.Program, H.Hours, ltrim(right(convert(varchar(25), H.HourTimeFrom, 100), 7)) as 'Time From', " & _
        "ltrim(right(convert(varchar(25), H.HourTimeTo, 100), 7)) as 'Time To', H.SubGroup,H.Area, H.ParticipantHour, H.VolunteerHour, H.Fiscal, H.EntryTime " & _
        "from tblOrgHours H " & _
        "JOIN tblOrgRegistrations R on H.RegID = R.RegID " & _
        "JOIN tblOrgActivities A on H.ActivityID = A.ActivityID " & _
        "Where H.AgencyID = '" & AgencyID & "' And H.ActivityDate >= '" & DTPicker1 & "' And H.ActivityDate <= '" & DTPicker2 & "'" & " " & String1 & " order by r.LastName,r.FirstName, H.Program, A.ActivityName, H.ActivityDate,H.HourTimeFrom"
        

Open in new window


esql = "select AgencyID from tblOrgProfile where [System Name] ='" & Combo1 & "'" 

If rec.State = adStateOpen Then
        rec.Close
End If

      rec.CursorType = adOpenStatic
      rec.CursorLocation = adUseClient
      rec.LockType = adLockOptimistic
      rec.Open esql, conn, , , adCmdText

Text1 = rec.RecordCount

If rec.EOF And rec.BOF Then
    Set DataGrid1.DataSource = Nothing
    MsgBox "There are no Records for this Query. ", vbOKOnly, "No Data Found"
    Exit Sub
    
End If

      
        Set DataGrid1.DataSource = rec
        
        
    rec.MoveFirst
    

Open in new window

0
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hi Experts,
I'm looking to modify the code below to obtain all values of given Caspio table and insert them into my Access table.
Function GetDataFromCASPIO()
    Dim objHTTP As New WinHttp.WinHttpRequest
    Dim docXML As MSXML2.DOMDocument
    Dim ResponseText As String
    Dim curNode As IXMLDOMNode
    Dim oNodeList As IXMLDOMSelection

    Set docXML = New MSXML2.DOMDocument

    Set objHTTP = New WinHttp.WinHttpRequest

    URL = "https://MyAccount.caspio.com/oauth/token"
    objHTTP.Open "POST", URL, False
    objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    objHTTP.Send "grant_type=client_credentials&client_id=MyClientID&client_secret=MySecret"
    ResponseText = Right(objHTTP.ResponseText, Len(objHTTP.ResponseText) - 17)
    access_token = Left(ResponseText, InStr(ResponseText, """") - 1)
    'Debug.Print access_token


    Set objHTTP = New WinHttp.WinHttpRequest
    'objHTTP.setRequestHeader "Content-Type", "application/json"
    URL = "https:// MyAccount.caspio.com /rest/v1/tables/MyTable "
    objHTTP.Open "GET", URL, False
    objHTTP.SetRequestHeader "Accept", "application/xml"
    objHTTP.SetRequestHeader "Content-Type", "application/json"
    objHTTP.SetRequestHeader "Authorization", "Bearer " + access_token
    objHTTP.Send
    'Debug.Print objHTTP.Status
    'Debug.Print objHTTP.ResponseText
    docXML.loadXML (objHTTP.ResponseText)

    strXPathQuery = "Caspio/Row"
    Set oNodeList = 

Open in new window

0
I have a couple of VBScripts that were generated a couple of years ago as one of the options in CuteFTP Pro. The scripts connect by FTP, go to my website, then upload or delete certain files. They've worked fine with no problems every month until recently.   Now, I'm getting this error message:

Error Message That Appears When Trying to Run the Program
With a little help from an expert here on EE, I think I've narrowed down what the problem really is. I don't think the problem is with CuteFTP.  I think it is connected with some type of Microsoft system operations, and I have a feeling that an expert versed in Visual Basic can help me get the scripts running again. It looks like the problem is connected with the "Library Not Registered" notation, but that's as far as I can go on my own technically.

Here's part of one of the scripts in question:
--------------------------------------------
' VBS Script Generated by CuteFTP (TM) macro recorder.
' Generated at: 4/8/2015 4:51:49 PM.
' Revised 9/1/2015
' MASTER Upload Spots Script - Oldies - Six Spots

' Create TEConnection object
Set MySite = CreateObject("CuteFTPPro.TEConnection")

' Initialize remote server host name, protocol, port, etc.
MySite.Host = "ftp.[mywebiste].com"
MySite.Protocol = "FTP"
MySite.Port = 21
MySite.Retries = 30
MySite.Delay = 30
MySite.MaxConnections = 4
MySite.TransferType = "AUTO"
MySite.DataChannel = "DEFAULT"
MySite.AutoRename = "OFF"
' WARNING!!! SENSITIVE DATA: user name and password.
MySite.Login = …
0
I just bought a Fingerprint Scanner SAGEM MORPHOSMART CBM Model MS0 1300 E2.  
Can anyone suggest me how to use it in visual basic 6.  I didn't find sdk anywhere.  Can anyone help me with some link or code. ?
0
I want to rename all of Mp4 files to 1 2 3 4 5 6 7 ... so on

but the numbers sequence should be based on the created date-time   so all of my files are created today but their timing for creating them are different.

so 1 should be the name of the latest time of creation of the Mp4 and then 2 should be the name of second latest created

how can i do this automatically?
0
Does anyone have an example that does something like the below for the attached ?

 1. sort by "Next Due Date" in "Oldest to Newest" order
 2. highlight rows were "Next Due Date" < today+7 to get everything that is due in the next 7 days
 3. print above section to default Windows 10 Pro printer
s002.jpg
0
I am having tiff images(front and rear images) in vb6 application. I am saving the tiff images to my local folder from fim and rim files and from there i am trying to print images.

Initially i tried to load the images to picturecox and tried to print the images, but tiff images are not able to print in this way. i am getting an error as invalid Picture.
.bmp and .jpg are working fine.

If pblnFlipped Then
        Set frmnewimage.img.Picture = Nothing
        frmnewimage.img.Picture = LoadPicture(mstrRearTiffImageFile)
        Else
        Set frmnewimage.img.Picture = Nothing
        frmnewimage.img.Picture = LoadPicture(mstrFrontTiffImageFile)
        End If
        Printer.PaintPicture frmnewimage.img.Picture, 100, 100
        Printer.EndDoc


so i am saving the picture to my local. but i am not under standing how to print images directly from the saved images. Please help me.

Thanks in Advance!!!!






What I have tried:

If pblnFlipped Then
       Printer.PaintPicture mstrRearTiffImageFile, 10, 10
       Else
       Printer.PaintPicture mstrFrontTiffImageFile, 10, 10
       End If
       Printer.EndDoc


mstrRearTiffImageFile and mstrFrontTiffImageFile are strings(rear image and front image). it consist of images which i need to print. based upon the image type (pblnFlipped) i need print images.
0

Visual Basic ClassicSponsored by Jamf Now

163K

Solutions

58K

Contributors

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.