Visual Basic Classic

164K

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 migrated vb6 to vb.net using the vs2008 wizard and it works fine But some controls are not visible on form.
 I can see them on control list in properties window but can not get them to be seen on the form in design time.
what am I missing?...
0
OWASP Proactive Controls
LVL 12
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

I'm trying to reduce the usage of Global variables in a rather large VB6 program.  Fabrice Lambert suggested using the Services Locator design pattern to access various dictionaries (or collections) instead of having a global dictionary.  This works great.  I have a factory class which has various support functions and properties which are used in many places in the program.  How can I use the factory functions without having a global object for the factory.  I can put a factory object in each procedure where it is used, but that seems like it will have a major impact on performance.
Private Sub ProcedureA
Dim oFactory as clsFactory
Dim myLongValue as Long
.
.
.
Set oFactory = new clsFactory
myLongValue = ofactory.LongValue
set ofactory = Nothing
.
.
.
End Sub

Open in new window


Any thoughts on this.  A global Factory object seems like the way to go, but OOP doesn't like global variables.
0
I have a 10 year old Access function that logs into a website and navigates to a search form and downloads data. However, the website has now changed and the function is useless. This site helped me create the code that has worked for many years. Basically I need help again. Unfortunately, I have forgotten many of the key points to the design of this function.

I am getting a
Run-Time Error '2147467259 (80004005)':
Method Busy of Object Webbrowser2 failed

In the past the browser would open the target page and enter my user name and password and login to the site. Currently, this is where the step is failing. Private Sub Command155 is where users would input their username, Pass word and date range that would be applied later in the procedure.

Private Sub Command155_Click()
'Assign the user inputs to variables that will be used in the Web application.
'Tell VBA what to do when the user does not input a date format
On Error GoTo NotADate

    myStartDate = Format(CDate(txt_StartDate), "mm/dd/yyyy")
    myEndDate = Format(CDate(txt_EndDate), "mm/dd/yyyy")
    myNAMC = txt_NAMC
    myUserName = txt_UserName
    myPassWord = txt_Password

    'Inform the user that this program is operating correctly.
    'MsgBox "Please wait, SKPI is updating!"
    ' I am just testing my variables here, this will be eliminated later.
    MsgBox "Start Date:" & " " & (myStartDate) & "   " & "End Date:" & " " & (myEndDate)
    Module1.SkpiUpdate
    'Module1.SKPI_NewDataImport_

Open in new window

0
Good afternoon,
I'm need some help with a script I'm using to clean up the profiles on the public pc's. I need to add some code to remove .bak files from the profile list. particularly this one, S-1-5-21-3822824043-2368925748-477173625-1177.bak For that matter, I could use a totally different script but I would prefer to just add it to this one.



@ECHO OFF

FOR /F "tokens=*" %%a IN ('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList"^|FIND /I "S-1-5-21"') DO CALL :REGDELETE "%%a"
GOTO CLEAN

:REGDELETE
FOR /F %%b IN ('REG QUERY %1 /V ProfileImagePath^|FIND /I "internet"') DO REG DELETE "%%b" /F
FOR /F %%c IN ('REG QUERY %1 /V ProfileImagePath^|FIND /I "TEMP"') DO REG DELETE "%%c" /F
FOR /F %%d IN ('REG QUERY %1 /V ProfileImagePath^|FIND /I "short"') DO REG DELETE "%%d" /F
FOR /F %%e IN ('REG QUERY %1 /V ProfileImagePath^|FIND /I "jobseeker"') DO REG DELETE "%%e" /F
FOR /F %%f IN ('REG QUERY %1 /V ProfileImagePath^|FIND /I "catalog"') DO REG DELETE "%%f" /F
GOTO CLEAN

:CLEAN
FOR /F %%b IN ('DIR C:\Users /B^|FIND /I "internet"') DO RMDIR /S /Q "C:\Users\%%b"
FOR /F %%c IN ('DIR C:\Users /B^|FIND /I "TEMP"') DO RMDIR /S /Q "C:\Users\%%c"
FOR /F %%d IN ('DIR C:\Users /B^|FIND /I "short"') DO RMDIR /S /Q "C:\Users\%%d"
FOR /F %%e IN ('DIR C:\Users /B^|FIND /I "jobseeker"') DO RMDIR /S /Q "C:\Users\%%e"
FOR /F %%f IN ('DIR C:\Users /B^|FIND /I "public"') DO RMDIR /S /Q "C:\Users\%%f"
FOR /F %%g IN ('DIR C:\Users /B^|FIND /I …
0
Hey,

I am trying to make a Microsoft word document that allows users not to edit content once the content controls are removed. My plan to do this was by restricting the editing to only filling in forms and then creating a code that removes the content control anywhere that there is text value. I am new to VBA and cant get the code to work properly. I can get it to remove the content controls when they are empty but when I try to remove them with content they do not disappear. I have attached the document that I cant get to work.

If anyone can help me that would be fantastic!

Thanks,

Max
Client-Journal-Template.docm
0
Lookup Error when search value is not foundDrop Down LookupHi,

  In my  ACCESS database, I have a table where I store company names and passwords.
 and form where I have two records - "AAA" and "CBS" . When searching for the record, if I enter non-matching value, then I get an error.
  Getting an error is ok, but it does not have what I call "graceful exit".
  For example, if I am typing "ab" and press [enter], I get an error message (as seen in the screenshot).
  What kind of visual basic code can I use to provide a graceful exit?

Thanks.
0
How do I convert these properties and such from vb6 to vb.net or c# prefably. Thank you.

Public Property Let Confirmed(Index As Integer, bConfirmed As Boolean)
    If bConfirmed Then
        sTransferOrder_Items(Index, GI_CONF_TO_ITEM_CONFIRMED) = vbChecked
    Else
        sTransferOrder_Items(Index, GI_CONF_TO_ITEM_CONFIRMED) = vbUnchecked
    End If
End Property
 
Public Property Get Confirmed(Index As Integer) As Boolean
    Confirmed = (sTransferOrder_Items(Index, GI_CONF_TO_ITEM_CONFIRMED) = vbChecked)
End Property
0
Hi Experts,
we have a site created in Caspio that has some required fields.
We realized that some of the required fields are coming thru w/o containing data.
So were told by Caspio that is probably due to those users using an old browser.
They created a field named user_agent that will capture which browser were used for each record data entry.
Now I created a list of all records with missing data in required field along with the data captured in this field named user_agent (browser).
See attached.
Wondering what are those values are and how can we sent a message informing this and this browser is not supported...
Thanks
Untitled.png
0
Hi Experts,

I have attached a VB Utility being regularly used by me. It is used to prepare some returns, where we input the data and the output is produced in the shape of some encrypted file format for onward submission. But it can also be used to prepare a correction return also. In that case we need to import a Consolidated file and then the return can be amended or extended.

What I presently do
--Download all the conso files

--Import the files one by one in above software.
>>Here we need to Select Form No (24Q / 26Q / 27Q / 27EQ).
>>Type of statement to be prepared is always "Correction".
>>Option to be selected "Import Consolidated File"

--Copy the data from the tabs and paste them in different sheets of Excel (Normally there are 3 Tabs, but data from 1st Tab is never copy pasted. There may be 4 tabs for the 24Q - 4th Quarter of a Financial year in which case the last 3 tabs are copy pasted)

Name of Tabs (from which data to be copied and pasted in Excel) in case of each Form
24Q >  Challan , Annexure I        (in case of 4th Quarter of FY tabs to be Copy pasted are Challan, Annexure I and Annexure II
26Q >  Challan , Annexure I
27Q >  Challan , Annexure I
2EEQ >Challan , Annexure I

Challan Data can be pasted in the same Excel Sheet for All Form Types, whereas for Annexure I and Annexure II, we need separate sheets for Each Form.

I wish some script (or anything like that even if that is in Excel) which can
0
I have a VB script that I want to adapt to remove a desktop link from the currently logged on user's Desktop.  It isn't working and I get no error messages - no nothing.

On Error Resume Next
Dim FSO, WSHShell, Regkey, Username, strFolder, UserPath, objShell

Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\"
Username = WSHShell.RegRead(RegKey & "LastLoggedOnSAMUser")
Username = Mid(Username,7) 

Set FSO = CreateObject("Scripting.FileSystemObject")
UserPath = "C:\Users\" & Username 
strFile = "C:\Users\" & Username & "\Desktop\CMS Supervisor*.lnk}" 
if FSO.FileExists(strFile) = True then  FSO.DeleteFile DesktopPath & "\CMS Supervisor*.lnk"

Open in new window

1
Amazon Web Services
LVL 12
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Hello,

I am running into quite an unusual problem and was wondering if anyone has experienced this issue before. I have an ActiveX Control that I have made that uses a Picture Box and displays an image from Azure blob storage by converting that image's memory stream into an image. I use this ActiveX Control for a Microsoft Access 2002 application. This ActiveX Control works great on forms, but on reports it doesn't display fully (Please see attached images). Anyone know why?
ActiveXFullyDisplayed.PNG
ActiveXNotFullyDisplayed.PNG
0
In my application, i have a common dialog component, on click of this component a dialog box will open where i can select a file and open it to get the list of account names that are there in the file.

The component was working fine, but from few days, when i click on this component my application is getting closed.

can somebody help me on this!!!!

Note: I have component added in my project. and the file is also present.
0
I had this question after viewing Failed to activate control vb.UserControl.
I have a similar problem and I know it is caused by two seemingly incompatible programs.
If I reinstall the app which reported the problem, the other one stops working and vice versa.
How can I get both apps to work in peace ?
0
How to create push message app for LAN in winform app like asp.net-SignalR
0
i want to write the code in vb6 (Visual Basic6) language to send sms through web api (after creating account in smsgateway.me site and mobile app in my android phone set) using json method (and how to get token) in vb6. Actuallay i know how to send sms using http url but unable to send sms through json). can you help in this case? thanks
0
When exporting text to a .tab file, then opening a Word doc, then trying to insert a portion of the tab file into this Word doc, I get an error message - "Run-time error '4605':  This method or property is not available because this command is not available for reading."  When I click on Debug, it then highlights the Selection.InsertFile lines.  I've never received this error before; however, I have a new PC, Windows 10, 32-bit OpSys (to allow DOS), and MS Office Professional Plus 2013.  I checked and the .tab file does exist.  Any suggestions?

    ChangeFileOpenDirectory "R:\fmExports\MastersandMacros"
    Documents.Open FileName:="woodrich_letterhead.doc", ConfirmConversions:= _
        False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
        WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
       
    ChangeFileOpenDirectory "R:\fmExports"
    Selection.InsertFile FileName:="woodrich4word.tab", Range:="", _
        ConfirmConversions:=False, Link:=False, Attachment:=False
0
In Example1.xlsx, Column "I" has words in each cell like Entire, Shared, SE.1/4, etc.  For every cell in Column "I" that has the word ENTIRE, I would like to add 7 rows below the initial row, copy everything from the initial row into the seven added rows and then renumber column "G"(Space?) from 1 through 8. (See Example2.xlsx).  How would I do this in Excel 2013?
Example1.xlsx
Example2.xlsx
0
Hi Experts,
Wondering if there is a way to link an Access 2003 application to an Excel XLSX file?
if not, can someone post code to convert file from XLSX to XLS?
Thanks
0
ciao a tutti, volevo sapere in che modo era possibile esportare dei dati da una tabella di un db su sql server in excel tramite framework .net su vb.net
Fino ad oggi uso questa procedura ma per tabelle con molti dati il procedimento impiega troppo tempo. Importo la tabella su un datatable o un datagridview per visualizzarla al front end, una volta caricata con una funzione che si basa sulla classe interop excel vado a ciclare tutte le righe della tabella e le scrivevo su un file excel.
Mi sono accorto che per tabelle molto grandi l'export dura troppo tempo, allora spesso ricorro all'importazione direttamente da excel sulla scheda dati/nuova query/da database/da database sql server. la scheda mi richiede il server, il database e la query e con pochissimo tempo con il net framework si caricano tabelle con molti dati, già convertite anche per ogni formato cella. La mia domanda è se la stessa procedura può essere richiamata da vb.net, quindi con una funzione che una volta passati i parametri di server,db,query scriva velocemente su un file excel (.xlsx)
0
Build an E-Commerce Site with Angular 5
LVL 12
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

How to edit 2 cell fields in multiple excel files in a folder/subfolders automatically using VBA based on starting name of file

For example I have a root folder of c:\master templates
Under that folder I have subfolders with clients names as the folders
Under each client folder I have folders with job numbers
Under those job number folders are the excel files that I want to change
They all start with the name of set_up sheet *
There could be 2 set_up sheet excel files or 3 or 5, it all varies based on client and job, but they are all named the same starting with "set_up sheet*"
I want to change 2 cells in each of these set_up sheet*.xls files for every directory/subdirectory that contains those files
Basically replace 2 fields
M14 with "Stick Out"
S14 with "Vending #"
Then I want to save each excel file back and close and then loop through and do the same thing for all the other excel files named the same thing in each directory/sub

Here is the code I have so far which I know isn't correct. It's just what I wrote by watching a youtube video on it. I know I am on the right track I just need some help

Sub LoopThroughDirectorytoedit()
Dim MyFile As String
Dim Filepath As String
Dim q As Long

Filepath = "C:\mastertemplates\"

MyFile = Dir(Filepath)

Do While Len(MyFile) > 0
If MyFile = "bookz.xlsm" Then
Exit Sub
End If

Workbooks.Open (Filepath & MyFile)
For q = 1 To Application.Worksheets.Count
Worksheets(q).Activate
Range("M14") = "Stick …
0
project to pragmatically click email "confirm" must be in VB6

the program must:

scan inbox
open email if keyword in subject line example  "Bitrex"
find button with keyword in it example  "confirm" and select it
capture the result screen and save in folder  

Im not sure where or how here on Experts i can post this , or even if I can , any help appreciated.
0
Hi

We have a simple application that was done by a predecessor. All it does is allows users to enter 'item numbers' and send to print. The item data is saved on a separate excel sheet in the same folder. All dll files, EXE. file and excel file are in the same folder. I've just copied this folder to a new machine trying to replicate the process. I can run the application but when I click send to print button on the application I get below error;

"Unhandled exception has occurred in your application if you click continue the application will..."

"could not load file or assembly microsoft.reportviewer.common version=12.0.0.0..."

I've tried installing the relevant files for above exceptions. However, think this is to do more with the 'Print' button on the application and coding behind it.
Please see attached.

Can someone advise what I need to do to get this to work please?

Thanks in advance.
Exception-Issue.docx
1
Wondering why the code below won't set as the selected item (a number 1-5) based on the database field value?

Thanks in advance for any help!

    sThisRdr = lstRdrPriority.Text
    
    Set rs = New ADODB.Recordset
    sql = "SELECT ReadOrder FROM FinishReader WHERE MeetsID = " & lMeetID & " AND ReaderNum = " & sThisRdr
    rs.Open sql, conn, 1, 2
    lstPriority.Text = rs(0).Value
    rs.Close
    Set rs = Nothing

Open in new window

0
This code only captures the first part of the page, I think because the whole page doesn't load until you scroll to the bottom of the page, which I don't know how to do programatically.

Set http = New WinHttpRequest

x = "https://www.flickr.com/photos/conationalguard/page1"

http.Open "GET", x, "False"
http.Open
http.Send
myval = http.ResponseText

Open in new window

0
MSComm1.Output = "AT\n" & vbCrLf <br/>
Sleep 100<br/>
MSComm1.Output = "AT+CSCS=UCS2\n" & vbCrLf<br/>
Sleep 300<br/>
MSComm1.Output = "AT+CMGF=1\n" & vbCrLf<br/>
Sleep 400<br/>
MSComm1.Output = "AT+CSMP=17,168,0,8" & vbCrLf<br/>
Sleep 500<br/>
MSComm1.Output = "AT+CMGS=" & Chr(34) & Text1.Text & Chr(34) & vbCrLf<br/>
Sleep 600<br/>
MSComm1.Output = Trim(txtMsg) & " " & Chr(26)<br/>
MsgBox "MESSAGE SENT"<br/>
0

Visual Basic Classic

164K

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.