Visual Basic Classic

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

What I was trying to do is on the Summary tab I wanted two buttons to initiate a pop-up with a close button that will display a chart for each of the EA chart and IR chart that is in the Charts tab.

Per the attached I had some help to do the same thing with a range of cells but was looking to see how this can be done with charts instead of a range of cells in this case.  See attachment.
C--Users-lfreund-Desktop-Excel-POP-.xlsm
0
Cloud Class® Course: CompTIA Healthcare IT Tech
LVL 12
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Hi All,
I'm working in VB6 (just to set the view).
I'm creating an ActiveX Dll.
I have an OCX which has various events.  The OCX needs to be on a form for it to do anything.
I have a class which isolates the OCX from the rest of the world - all of the OCX properties are supplied by passing through the class
So far, this all works ok.
Where I'm running into problems is trying to get the events from the OCX out of the DLL to be used by the main program.
I have looked and have not been able to find anything.  There are lots of examples showing the WithEvents, but none from a DLL.
Maybe what I want to do isn't possible.
0
Dear Sir , I am using below mention code for pdf generation from crystal report. But in this process every pdf is opening in the pdf reader. I don't want to open the every file.so please suggest solution.

 Report.ExportOptions.ApplicationFileName = Text3.Text & "\" & nFileName & ".pdf"
                Report.ExportOptions.DestinationType = crEDTApplication
                Report.ExportOptions.DiskFileName = Text3.Text & "\" & nFileName & ".pdf"
                Report.ExportOptions.PDFExportAllPages = True
                Report.ExportOptions.FormatType = crEFTPortableDocFormat
                Report.DisplayProgressDialog = False
                Report.Export False
0
Hi,

I have code written in asp.net and c#. Please let me know how to convert the code into classic asp and vb? I need to display the Logon_user and last visited date and time. I am storing the datetime in database.

Default.aspx

<asp:Label id="username" runat="server"><br>
<asp:Label id="lastvisited" runat="server">


Default.aspx.cs

Protected void PAge_load
{
username = GetUserName();
lastvisited = (string) Session["LastVisitedDateTime"];

}

public string GetUserName()
{
string sUserName = Request.ServerVariables["LOGON_USER"]
sUserName = sUserName.Substring(sUserName.Indexof("\\") + 1);
return sUserName;
}

Global.asax.cs
protected void Session_start(object sender, EventArgs e)
{
string sUserName = GetUserName();
string sDateTime= DateTime.Now.ToString();
Session["LastVisitedDateTime"] = "";
if(sUserName != "")
{
Session["LastVisitedDateTime"] = GetLAstVisitedDateTime(sUserName);
}
UpdateLastVisitedDateTime(sUserName, sDateTime);
}


}

private string GetLAstVisitedDateTime(string sUserName)
{
SqlDataReader myDataReader;

String sLastVisited = "";
myDataReader = GetLastVisitedDateTime(sUserNAme);
while myDataReader.Read()_)
{
sLastVisited = mydatareader.getstring(mydatareader.getordinal("LastVisitedDateTime"));
}

return sLastVisited;
}

private void UpdateLastVisitedDateTime(string sUserName, string sDateTime)
{
SqlConnection objcon = new SqlConnection(connstring);
SqlCommand cmd = new SqlCommand("proc", objconn);
cmd.CommandType = 

Open in new window

0
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
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 need to compare 2 tables with exactly the same structure and update TableA according to what it is on TableB for all records that they are different.
This is the SQL needed.
UPDATE Patient_Progress_Notes INNER JOIN Patient_Progress_Notes1 ON Patient_Progress_Notes.PN_ID = Patient_Progress_Notes1.PN_ID SET Patient_Progress_Notes.Patient_Last_Name = nz([Patient_Progress_Notes1].[Patient_Last_Name]), Patient_Progress_Notes.Patient_DOB = nz([Patient_Progress_Notes1].[Patient_DOB]), Patient_Progress_Notes.[Date] = nz([Patient_Progress_Notes1].[Date]), Patient_Progress_Notes.Nurse_Name_Stamp_PN = nz([Patient_Progress_Notes1].[Nurse_Name_Stamp_PN])
WHERE (((nz([Patient_Progress_Notes].[Patient_Last_Name]))<>nz([Patient_Progress_Notes1].[Patient_Last_Name]))) OR (((nz([Patient_Progress_Notes].[Patient_DOB]))<>nz([Patient_Progress_Notes1].[Patient_DOB]))) OR (((nz([Patient_Progress_Notes].[Date]))<>nz([Patient_Progress_Notes1].[Date]))) OR (((nz([Patient_Progress_Notes].[Nurse_Name_Stamp_PN]))<>nz([Patient_Progress_Notes1].[Nurse_Name_Stamp_PN])));

Open in new window

However since these tables have over 85 fields..(each).

The above contains the SQL needed for the first four fields.

Can someone help me build this SQL for the rest of the fields, via code by looping thru all fields on the table and adding it to the string?


Thanks in advance.
0
Is there a formula that I can use in a Excel spread sheet that will look up data on another tab and fill in the cell with info based on two different rows.

For example I have a file with tab1 and tab2. On tab1 I have two table with cells that indicate certain things like complete or not complete, one for 2017 and one for 2018. On tab2 I have a list of the data with a status column and a year column. I need two formulas that will look at the status column for a particular year and fill in a number for each row that applies. Kind of like using a COUNTIF formula but based on a particular year. Imagine a file with thousands of lines and dozens of years!

Attached a file with an example of what I am talking about.
Excel_Formula_Sample.xlsx
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
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Hi Experts,

I've been running VB6 / Visual Studio 6.0 Pro Service Pack 6 on my Windows 10 PC for a year or two.

I also have Visual Studio 2013 Pro installed.

But recently any attempt to open the VB6 IDE is greeted with a number of dialogs (1 minute screencast).

The first dialog comes up a few times:

Please wait while Windows configures Microsoft Visual Studio Professional 2013...
Gathering required information...

The Visual Studio Professional 2013 dialogs run to completion, then this dialog opens up:

Windows Installer
Preparing to install...

That dialog never shows any further information and does not finish.

I'm locked in an endless loop.
If I terminate the running task and start again, I can never open a project.

Regards,
Leigh
0
I'm using farpoint fpspread grid control inside a old legacy VB6 application.
That is a grid that was used in old VB6 desktop applications

This is the version of VB6 im using:

vb6version.PNG
This is the user's guide for the fpspread control:
Spread 8.0 Documentation User’s Guide
http://helpcentral.componentone.com/NetHelp/Spread8/WebSiteHelp/title.html

I have a form with a fpsread control on it , something like this:

fpspreadcontrol.png
The data I used to fill the fpspread comes from a table in a sql server database.

The data in the fpspread is not sorted on page load. I want to sort it by one of the date columns.

In the fpspread documention for sorting, it mentions you can either sort using the Spread Designer or set the sorting programmatically with code.
I would like to set the sorting on the fpspread with code.

Sorting Data
http://helpcentral.componentone.com/NetHelp/Spread8/WebSiteHelp/data32.html#659075


If I was using the Employees table from the Northwind database,  and my fpspread was called grdEmployees

How would I set the sort on the fpspread so that on page load it is sorted by HireDate Descending ?

The Employees sql server table looks like this.
I have a stored procedure doing a Select * From Employees to return all the columns from this table.Then in vb6 application I have a function that calls this stored procedure and creates a record set. Then I bind the recordset to the fpspread grid.
I …
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
Hi Experts,
We have the following code to print out signatures on an Access report.
Function ViewPic()
'View Pic From DB
Dim OutFile As String
Dim strSql As String
    Dim StartX  As Long
    Dim StartY  As Long
    Dim EndX    As Long
    Dim EndY    As Long
    Dim Width   As Long
    
If Len(Me.Signature & "") < 20 Then Exit Function
 If InStr(1, Me.Signature, "]", 1) <= 0 Then Exit Function
  
  Dim str As String
  str = "{" & """values""" & ":" & Me.Signature & "}"
   



        Dim Json As Dictionary
        Set Json = JsonConverter.ParseJson(str)
        Dim Values As Variant
     
        
        Dim Value As Dictionary
    
        Me.ScaleMode = 3
        
        For Each Value In Json("values")
         'Report_Report1.Line (Value("lx"), Value("ly"))-(Value("mx"), Value("my")), vbRed
         Me.Line (1200 + Value("lx"), Value("ly"))-(1200 + Value("mx"), Value("my")), vbBlack


End Function

Open in new window


However for some reason when signature is too short nothing gets displayed.

How is it possible to display even if its only a dot?

Thanks in advance
0
am using vb6.0 ..this above solution helped me to enter data into msflexgrid..But if i have to enter 10 enteries at run time how can i increment the no of cells??
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
Free Tool: ZipGrep
LVL 12
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Hello,

I would like to automate Nuance to convert pdf to excel.

with the vba code below in can open the mypdf file with Nuance , but i would like to automatically control Nuance to  convert my whole pdf to excel using a vba code and save it automatically to my open excel file . Thank a lot for your help.

Dim varRetVal As Variant, strFullyPathedFileName As String, strDoIt As String
strFullyPathedFileName = "C:\Users\Desktop\Invoice\mydoc.PDF"
strDoIt = "C:\Program Files (x86)\Nuance\Power PDF 20\bin\NuancePDF.exe " & strFullyPathedFileName
varRetVal = Shell(strDoIt, l)
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
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

Visual Basic Classic

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.