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

Hi Experts,
I have this question after solving the following..
https://www.experts-exchange.com/questions/29108803/Script-to-read-all-files-of-specific-folder.html#acceptAnswerByMember
In that question I got a script how to count all records of files in one folder.
However now I need to know from that count how many are under one specific category.
Therefore I thought the best way would be to concatenate all files into one, just ignoring the headers.
And from there I will link to MS Access and get the results from a query.
Anyone has either a script for that or another way to accomplish the task?
Thanks in advance.
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.

Hi, cannot use "line input #n, string.variable" anymore to read a text file line by line in VB 2010. There are several methods, none of which seem to work including the below.
Can you suggest a simple method that does work.

The below when debug mode was started did nothing. The text file had three lines in it, "line 1", "Line 2" & "Line 3".

Imports System
Imports System.IO
Imports System.Text
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim fileReader As System.IO.StreamReader
        fileReader = My.Computer.FileSystem.OpenTextFileReader("C:\myfiles\test.txt")
        Dim stringReader As String
        stringReader = fileReader.ReadLine()
        MsgBox("The first line of the file is " & stringReader)
    End Sub
End Class
0
Hi.
I would like to have a complete code that reproduces. avi files in the. dll. OCX and other files in a PictureBox written in Visual Basic 2010 Express.
So to speak for example that it reproduces an AVI file while it is copying a file (I have the code in Visual Basic 6 I enclose and I cannot get it to work in Visual Basic 2010 Express).
From what I could understand by reading the various forums in Internet there is also the possibility of embedding an AVI file by transforming it into a resource and uploading it to Visual Basic 10 Express, if it were so it would be good to know how to create that resource, embed it in Visual Basic 10 Express and play it in a picture box while the application is working (always with full code).
is clear transparency effect and continuous play.
I would want complete code to download with any clarifications.
0
I have the following code which is working perfectly:

Public Sub MakeThisConfidential()
Application.ActiveInspector.CurrentItem.Sensitivity = olConfidential
Application.ActiveInspector.CurrentItem.Save
' MyMsg = MsgBox(Prompt, 0, "This message has been marked Confidential and will be encrypted by Fusemail")
MyMsg = MsgBox("Click OK to accept status" & vbCrLf & "This will encrypt the Current Message using fusemail", 0, "This message has been marked Confidential")
End Sub

Sub ToggleSensitivity()
    If ActiveInspector.CurrentItem.Sensitivity = olConfidential Then
        ActiveInspector.CurrentItem.Sensitivity = olNormal
        MyMsg = MsgBox("Click OK to accept status" & vbCrLf & "This will NOT encrypt the Current Message using fusemail", 0, "This message has been marked Normal")
    Else
        ActiveInspector.CurrentItem.Sensitivity = olConfidential
        MyMsg = MsgBox("Click OK to accept status" & vbCrLf & "This will encrypt the Current Message using fusemail", 0, "This message has been marked as Confidential")
    End If
End Sub

Open in new window


I have attached it to 2 separate buttons
I want to be able to run the macros and change the current button image. The image is added by the outlook interface:
In the New Mail window:
File - Options - Customise Ribbon - Main Tabs - New Mail Message
There is a group in here which has buttons with the macro's attached
0
Dear Experts,

Before I go into my question I want to give you information about what I am working with.

Programs and their version
• Word 2013
• Excel 2013
• VBA 7.1

Explanation of the problem
I have a Word document that has both checkboxes and textboxes in it. I am looking for an Excel VBA code that can check a specific checkbox in the Word document based on an excel cell saying “Yes” (checked) or “No” (not checked). Each checkbox thus needs to be linked to a different cell.

Word has 3 types of checkboxes:
• Check box content control
• Check box form field (legacyforms)
• Check box (activeX controls)

I am using the Check Box Content Control. For this checkbox I do not find any clear excel VBA codes online that are used to check these checkboxes in Word. Is there anybody that knows how this can be done. Please also inform me if it only works with the other checkboxes and not with the content controls.

Please be informed that I also placed this question on another forum linked here:
http://www.vbaexpress.com/forum/showthread.php?63148-Use-Excel-VBA-to-check-context-control-checkboxes-in-a-Word-file

Your help is much appreciated. Many thanks in advance .

kind regards,

Sustainable
0
I am an Access programmer. I posted a question to convert access application to web based.  Now I am planning to move to web development. I came to know there is no way you can convert or move directly to web based programs.
I appreciate if you show some guidelines to start a web program (as if I am new to development).
Appreciate your help.
0
Hi Experts,

I have following code to convert from characters into signatures.
  
  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
        
        If Len(Signature & "") > 1000 Then
    
            Me.ScaleMode = 3
            Me.LabelPatientSignature.FontSize = 8
        Else
            Me.ScaleMode = 1
            Me.LabelPatientSignature.FontSize = 7
        End If
        
 'If Len(Me.Signature) < 200 Then Me.DrawWidth = 5
 
        For Each Value In Json("values")
        If Len(Signature) > 100 Then
            Me.Line (1200 + Value("lx"), Value("ly"))-(1200 + Value("mx"), Value("my")), vbBlack
        Else
            Me.Line (1200 + Value("lx"), Value("ly") - 5)-(1200 + Value("mx") + 10, Value("my") + 5), vbBlack, BF
        End If
         'Me.Line (1200 + Value("lx"), Value("ly") - 5)-(4000, Value("my") + 5), vbBlack, BF
'Me.Line (1200 + Value("lx") - 5, Value("ly") - 2)-(1200 + Value("mx") + 5, Value("my") + 2), vbRed
        Next Value

Open in new window


So for example the code would take the following, stored in signature field

Open in new window

0
Run-Time Error Received
Receiving the above message (Run-time Error -2047012889 The Server Name or Address could not be resolved') when using a MSXML2.XMLHTTP60 object to send a POST request to the specified URL.

Any ideas where to look?

NOTE : The code is VB6

I've tried a few things with security etc, but still getting the same response.

The general code is as follows (Note the ApplIcation ID has been replaced with the Generic Note)

   Dim myMSXML As MSXML2.XMLHTTP60
   
    Dim AuthURL As String

    AuthURL = "https://identitysso.betfair.au/api/login"

    Set myMSXML = CreateObject("MSXML2.ServerXMLHTTP")
     
    myMSXML.open "POST", AuthURL, False
    myMSXML.setRequestHeader "Accept", "application/json"
    myMSXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    myMSXML.setRequestHeader "X-Application", "<Application Code>"
   
    myMSXML.send "userName=" & sUserName & "&password=" & sPassword
0
Hello Community,

I want to know how can I integrate a Credit Card Processing into a VB.NET Windows Application. I want to develop a POS including this module.
Any sugesstion or recommendation about my request?.

Regards,
0
MS Word document.  This document is pulling field data from another system.  Upon open, I need all RICH TEXT field text to turn purple.  Any ideas?  Possibly a macro?

Thank you!
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.

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'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
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
0
I have an ongoing problem sending emails from a VB application sitting on Windows 10 boxes running Outlook 2010.
The application uses the inbuilt MAPI control in VB and sends mail fine when outlook is closed, but when it is open, I am getting the dreaded Error 32002: Unspecified Failure has occurred,sending mail.
I have the read about fixes in place in the code (ie: msgNoteText not empty and using ResolveName after recipients are added)
It seems like the application cannot gain access to the outlook object when outlook is open.
Running everything as admin.
I have searched extensively for a solution to this, but to no avail.
I wonder if anyone can help!
Andrew
0
Eclipse has tabs File,Edit,Navigate,Search, Project etc at top

Under project there is Clean and 'Build All' options to clean and build 10 different projects(project_1, project_2....project_10) i have at one stroke

but after doing that i get error as below for project_10
Error:Counld not fine or load main class com.xyz.zbc.drivertesting.Sample.java


if i do maven install on project _10 then above error is resolved but later stage i get

javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]


how maven install or maven build is different from Eclipse-->Project--->Build All
0
Hi,
I need to create .exe file in Autoit which will acheive this:

search c:\xml\ folder for xml filename (specific portion in a file name) that i supply/input in textbox and show it in the listbox , then have another textbox which i can give another name and change the name i choose from listbox .

let say there is xmls files in this folder:
c:\xml\

1. 658 961324913 20180422213033.xml
2. 688 9415460918 20180422221407.xml
3. 761 963837127 20180422215149.xml
4. textfilename.txt

i insert/search in the search textbox for : "9415460918"  (it will search only the number in between 2 spaces) from the  files in the folder
the search botton will list only  file number 2 (xml file)
I insert in another textbox new name like : "2154632810"
it will change the filename to : 688 2154632810 20180422221407.xml


i have play with some example that maybe help around:
#include <GuiConstantsEx.au3>
#include <File.au3>
#include <Array.au3>

;GUI
GUICreate("Rename XML files", 300, 500)
$sourceFolder = GUICtrlCreateInput("Source Folder", 10, 10, 280, 20)
$add = GUICtrlCreateButton("Search", 10, 35, 75, 20)
$mylist = GUICtrlCreateList("", 10, 60, 280, 300)


GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $add
            $sFolder = ControlGetText("Rename XML files", "", "Edit1")
            Local $FileList = _FileListToArray($sFolder, "*.xml")

            If @error = 1 Then
                MsgBox(0, "", "No 

Open in new window

0
I have a cloud based application that send email using ( VB6 VBSendMail)  we have been using SMTPTOGO to SEND emails but have recently signed up for Microsoft Exchange for our company email and would like to use Microsoft Exchange for our cloud server to send emails.

We have the following setting setup which is the same as our Outlook settings
SMTP Server:  smtp.office365.com
Login:   me@MyCompany.com
Password:  MyPassword
Outgoing SMTP Port:  587

Of course this does not work can anyone give me the correct settings.
0
Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Hello,

refering to https://www.experts-exchange.com/questions/27146781/out-of-memory-error-win-7-64bit-vb6-software.html

I've got the same problem, unfortunately the solutions is very common: "...it was a dll running in the background..."
May you give me more information about "which dll was running" and what does "...ONly showed up in win 64bit.." mean
0
I have an excel file in 2003 version which I am using as a template in my VB 6.0 application, now if I open it in 2016 and save as 2003 xls format then it runs slow in my application.

But if I open the file in 2003 version and simultaneously open excel 2016 blank worksheet side by side and then copy the contents of worksheet from the file opened in 2003 and paste in 2016 blank worksheet and save as 2003 xls format then it runs fast in my application, but here the formatting which is there in 2003 worksheet is lost. I want to retain the formatting also while pasting from 2003 to 2016 excel.

Please suggest.
0
Hello ;
I have an Excel file with a drop-down list in C7 and the folder name in C9 and the file name in C8.
I have a macro that saves me in PDF page by page with the file name on the correct folder name.
I want a macro that scrolls the drop-down list and saves in PDF each state on its folder with their names.
Folder name: C9
File name: C8
The attachment file
And the two macros.
Thanks in advance. and file attached

manuel macro
Sub PDF_Print()

'Déclaration des variables

    Dim NomDossier As String

    Dim CheminDossier As String

   

    On Error GoTo 1

   

    'Nom de dossier

     NomDossier = Range("C9")

     CheminDossier = "P:\COM-RET\COM-RET-PIL\Busines Review\PDF Buisnes Review\" & NomDossier & "\"

   

    If NomDossier = "" Then Exit Sub

 

    'Enregistrement au format PDF

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

    CheminDossier & "Business Review " & Range("C8").Value & ".pdf", quality:= _

    xlQualityStandard, includedocproperties:=True, ignoreprintareas:=False, _

    from:=1, to:=1, openafterpublish:=False

 

1

End Sub
Enreg_Auto_ListeDeroulante-v1.xlsx
0
HI there, I am using SSRS and have a problem where my grand total on the last page of the report will only calculate the the times of the pages that have been shown. In other words, if its a 3 page report and I run it and view the first page then skip to the last it will calculate the first and the last missing out page 2. If however, I run the report and go through each page using the next button it then calculates the total correctly.

My total is a SUM of a previous total and both are code elements within the report, after doing a bit of research I found out that this is why, the code elements only fire on the page that is in view.

My 2 code elements are:

Public shared dim totalJobTypeRateTotal as Decimal 

Function AddTotal(ByRef JobTypeRateTotal AS Decimal) AS Decimal 
 
                totalJobTypeRateTotal = totalJobTypeRateTotal + JobTypeRateTotal
                return JobTypeRateTotal

End Function

====This function calculates row items based on a lookup that finds the specific rate for each job type=====

 Public Function GetTotal()
                return totalJobTypeRateTotal
End Function

====This is the grand total at the end of the report group that will only calculate the total of the AddTotal function expression on pages that have been viewed====

Open in new window


How do I get the 2 code calculations to produce a grand total correctly without having to scroll through each page?
0
Hello David,

I saw your blurb here on Macro for Outlook for set up alert for not receiving email, from the description it is exactly what I am looking for, can you share the code? and procedure to set it up.
0
I wrote this code to export a batch of mail items to a text file - runs okay but much of the text is undecipherable symbols

I am trying to process error messages that I got from  a recent "eblast" so I can take measures to correct email addresses that have errors.

Is there an easy way to merge these emails into a single text file that is legible?

Sub Export_Emails_Subject_and_Body_To_A_Combined_Text() '01-18-2018a
    Dim NumberOfItems As Double, TotNumberofItems As Double
    Dim objOL As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objItems As Outlook.Items
    Dim FromPstFolder As Outlook.Folder
    Dim Item As Object
    Dim MailItem As Object 'Outlook.MailItem
    Dim j As Long
    Dim sfileTofldr As String
    
    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")

    NumberOfItems = 1

    MsgBox "Pick From Folder"
    Set FromPstFolder = objNS.PickFolder

    sfileTofldr = InputBox("Select the Name for the Text File", , "j:\Personal\OutlookData\" & FromPstFolder.Name & "-" & Format(Now(), "yyyy-mm-dd") & ".txt")
    
    For Each Item In FromPstFolder.Items
          Set MailItem = Item

'to Folder
        If FileExists(sfileTofldr) Then
            Open sfileTofldr For Append As #1
            Write #1, "xxx" & Format(NumberOfItems, "0000") & vbNewLine & MailItem.Subject & vbNewLine & MailItem.Body
        Else
            Open sfileTofldr For Output As #1
            Write #1, "xxx" & 

Open in new window

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.