An investment in knowledge
pays the best interest.
-Benjamin Franklin
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  


Visual Basic Forum
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on Google Plus Richard Rost on LinkedIn Email Richard Rost

This forum is for the discussion of Visual Basic programming and development.

Click Here To Subscribe to this forum and receive an email update whenever new posts are added, just scroll down to the bottom of this page and enter your email address in the comment form.

Permanent Link
Keywords: vb forum visual basic
Post New Topic

Read Determine case in combo box by Alex H @ 6/30/2019
How is strMediaType being set, is this a input that a user can input?

I tend to change the case first then you know you only have to check say all lower.

The other option is to intercept the key entry and force it to be upper/lower etc then only check for the allowed option.
Show Just This Thread        Post Reply
Read Determine case in combo box by Kevin Robertson @ 4/19/2019
Hi Alex,

I am looking for a more efficient way of writing the following code;

'set the case for items in combo box
If strMediaType = "cd" Or strMediaType = "Cd" Or strMediaType = "cD" Or
strMediaType = "dvd" Or strMediaType = "Dvd" Or strMediaType = "dVd" Or
strMediaType = "dvD" Or strMediaType = "DVd" Or strMediaType = "dVD" Then
strMediaType = Strings.StrConv(strMediaType, vbUpperCase)
strMediaType = Strings.StrConv(strMediaType, vbProperCase)
End If
Show Just This Thread        Post Reply
Read Vscroll in VB 2012 by Kevin Robertson @ 6/14/2018
I am attempting to add a spinner button using the vscroll control in vb 2012 to change a numeric value in a label. How do I determine which button is clicked on (up or down)?
Show Just This Thread        Post Reply
Read VB6 App in Win10 Store by Alex Hedley @ 12/31/2017
Putting (my VB6) Windows Apps in the Windows 10 Store - Project Centennial

Find those old apps and get them published
Show Just This Thread        Post Reply
Read VB6 on Win10 by Alex Hedley @ 12/31/2017
Please vote

Include Visual Basic 6.0 by default on the next version of Windows !
Show Just This Thread        Post Reply
Read ArrayList Object by Kevin R @ 8/9/2017
I need to store the values of a list of in VB2012 for later use. How do I use the ArrayList Object?


Reply from Alex Hedley:

If this just while running the program or do you need to save it to disk?

Dim list As New ArrayList


For Each num In list



list.Insert(0, 20)

Show Just This Thread        Post Reply
Read Convert from a string by Kevin Robertson @ 3/5/2017

How do I convert "+" to + to use in a calculation. I'm using VB 2015.


Reply from Alex Hedley:

I'm sure I did something like this in Uni years ago using java with Stacks, pushing and popping values and then performing the calculations.

Are you writing a Calculator app?
Can you not have a + button and perform the operation that way?

You could have a Switch or If statement and compare the string "+" and if so do the operation.

Maybe the Eval() function?
VBScript Eval() (from the awesome ss64)
Eval("1 + 1") returns 2.

People have tried to write there own for .NET with Reflection etc, have a search there are a number.
Show Just This Thread        Post Reply
Read Creating a file by Kevin Robertson @ 2/11/2017

The file needs to store passwords so I don't think a database would be a good option.

Reply from Alex Hedley:

Are there many?
What are their purposes?

You could encrypt them and store them in the app.config
Show Just This Thread        Post Reply
Read Creating a file by Kevin Robertson @ 2/11/2017

I am currently working on a security application using VB 2015 and need to create a file that only my program can write to and read back into the program. What is the best way to go about this?

Reply from Alex Hedley:

Hi Kevin,

What's the ultimate goal?

Can you not store the data in a database, that way you can set permissions against that.

There are a couple of options but none that are great.
Ultimately a user with Admin privileges would be able to access the file and delete or modify.
Open the file in exclusive mode, only works when the app is running.
Create an account and set permissions on the folder and file that the app can access.
Make the file protected with a password, you could zip it using a lib.
Show Just This Thread        Post Reply
Read Visual Basics Is there a link for a free download by Lynne F @ 4/21/2016
Thank you for the information.  If I have finished the Access Beginer course and the Access Advanced course should I continue with the Developer course or the Advanced Microsoft course?  (I am brand new to VBA)

Reply from Alex Hedley:

The Advanced 300+ series shows this, it's using Access 2003 but nothing much has changed in the code, it's just the UI of Access that is different.
Show Just This Thread        Post Reply
Read Visual Basics Is there a link for a free download by Lynne F @ 4/11/2016
Hello, Would like to learn VBA.  I started the course and it says I need Visual Basic 6.  Can anyone give me a link for the program or a newer version?  I am running Microsoft 13.  Thank you.

Reply from Alex Hedley:

VB6 is now out of date, if you have an MSDN license you can still download but it's better to start learning VisualBasic.NET or C#.
On an aside VBA is quite different to VB6 and C# etc.
This course doesn't teach VBA, its covered in the Advanced Microsoft courses instead.
Show Just This Thread        Post Reply
Read Access and VB by Mitch @ 2/5/2016
I'm not sure, but I think it's an event procedure.

Reply from Alex Hedley:

if you choose Event Procedure then click the ... does it open the VBA Editor?
Show Just This Thread        Post Reply
Read Access and VB by Mitch @ 2/4/2016
I followed Richard's Student Attendance tutorial to create a database. I was able to follow it all the way to the point where he puts in the vb code for the "Go" button. The problem I'm having is; I'm using Access 2016 I don't see a way to just type the code in. Can you help me. Thanks

Reply from Alex Hedley:

Are you using an embedded macro or an event procedure?
Show Just This Thread        Post Reply
Read Databases and VB by Eddie @ 3/29/2015
I just have a question about what the best approach would be for a project I want to work on since I've never worked with access or databases.

Essentially I want to create a database and have a program written in vb (using express 2013) pull data from the database and display a lot of that info based on users filtering or searching for something specific.

I know I can create a database directly in visual studio and I just started watching your Access tutorials but I don't know what the advantages of one over the other is and how easy it is to work with each one. I've used LINQ queries briefly in vb and I saw you can create a query incredibly easy in Access from your video. Can you export those queries to a vb program or get the code for the queries from Access?

I want to have a list box that's populated with data from a field (lets say name), then when the user selects a name in the listbox it displays other specified data associated with that name, similar to how you filtered the results based on state and had it only display the first and last name.

I guess my question is if I create everything using Access, including queries and all this stuff, would I be able to move everything into a VB program? Or would it be easier to just do everything (including the database creation) inside of visual studio? In the end I want to distribute this to others so I don't want something that will require Access to use.

Thanks in advance

Reply from Alex Hedley:

I show a quick way of connecting to an Access db in .NET
Here you can build the SQL string dynamically or you could add filters to the grid based on your selections.
You can connect the db in .net and have it in your connections tab and work with it directly with the gui.
Show Just This Thread        Post Reply
Read How do I run a free visual basic code in my comput by Ike @ 3/24/2015
But if the vb later versions are better, maybe I should start learning them rather than vb 6

Reply from Alex Hedley:

It makes more sense as these are new technologies and are updated and supported
Show Just This Thread        Post Reply
Read How do I run a free visual basic code in my comput by Ike @ 3/24/2015
I have visual basic 6. D codes were downloaded from the web, and it contained several folders with different files.  The folders included oxc, forms, modules etc.d codes were said to run on vb 6, vb5, etc. They said u can copy the files one after the other or just import it. But I don't know how.

Reply from Alex Hedley:

You can create a new Project and add them to the Explorer
See the VB Courses for more info
Show Just This Thread        Post Reply
Read How do I run a free visual basic code in my comput by Ike @ 3/22/2015
Hello. I just installed Visual Basic. I started learning 2 days ago. I now found codes I would love to run. How do I copy and paste these codes to my computer to run them? Is it in the codes area that they will be pasted? Do I need to save it afterwards?  How to I run it? If I download the free codes, please how do I copy the codes? Do I need to download any other program to be able to run the free codes? If I write programs for other people,  should they have visual basic to be able to run the programs?

Reply from Alex Hedley:

Is this Visual Studio Express 2010/2012??
Is it just a .vb file or C#
Is it a full solution, with other files (.sln)
This should all work with VS.
They will probably need .NET Framework on their machine but that's quite likely.
Show Just This Thread        Post Reply
Read VBA Code Query and Form Control to send Email by Shepherd C @ 12/2/2014
Thanks Alex,

I have renamed the fields to get rid of the spaces ("Mgr's Name") to ("MgrsName") but I still get "Run-time error 3061 Too Few parameters. Expected 1 on the line "Set rst = dbs.OpenRecordset("Probation Details_emailing", dbOpenForwardOnly)."
Yes the QUERY "Probation Details_emailing" contain these Fields that I am trying to access in my Recordset.

Any further help please!


Reply from Alex Hedley:

Can you run the Query from the navigation pane and it displays ok?
Show Just This Thread        Post Reply
Read VBA Code Query and Form Control to send Email by Shepherd C @ 12/1/2014
Dear Richard Rost,

I am disparate I need your help Richard! I have a workflow written in VBA code to send emails with details about employees who are on probation.  Ideally we would like this workflow to send emails to the HR Coordinator by simply opening the relevant employee s form and clicking on the  Send Email  button. The email should pick up the Manager s name from the rst.Fields( Mgr s Name ) as set up in the code below. The problem I am facing is that if I put reference to some Form control in the Design View of the Query it does not work. I am getting the error message:  Run-time error  3061  Too few parameters. Expected 1 . However, if I but if I put reference to the value in the Query s Design View i.e. the employee number it works. The HR Co-odinator is not that technical and she does not want to go through the trouble of going to the Design View to populate a employee number each time she wants to send an email.

How to I correct the VBA code to work. Below is the VBA code.



Private Sub Command84_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strTo As String
Dim strSubject As String
Dim strMessage As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Probation Details_emailing", dbOpenForwardOnly)
Do While Not rst.EOF
strTo = rst.Fields("HR Coordinator Email")
strSubject = "Probation Report" 'could be made available
strSubject = "Probation Report" 'could be made available
strMessage = "Dear " & rst.Fields("Mgr's Name") & vbNewLine & vbNewLine & _
"Employee name probation period ends on date.  Are you happy for me to issue a congratulatory letter?" & vbNewLine & vbNewLine & "FYI - I shall send the letter out on your behalf and it will have the following wording.If you would like to amend or add any comments please include them in your reply.  I will also arrange for a copy to be placed onto the employee's personnel file." & vbNewLine & vbNewLine & _
"I am pleased to confirm that you have successfully completed your probation period with PickSP Consulting Ltd on (date will be entered by HR) and I would like to take this opportunity to wish you every success in your future employment with us." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "Many Thanks for your time." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "Joseph Jones" & vbNewLine & "HR Co-ordinator" & vbNewLine & vbNewLine & "222222/ 7777777777" & vbNewLine & "Email:"

DoCmd.SendObject acQuery, "Probation Details_emailing", "ExcelWorkbook(*.xlsx)", strTo, "", "", "Probation Report", strMessage, False, ""
'close the objects
'destroy the variables
  Set rst = Nothing
  Set dbs = Nothing

End Sub

Reply from Alex Hedley:

Hi Shep,

Firstly try not to have spaces in your FIELD and QUERY names, it can cause issues when used in code.

I'd change the FIELD from ("Mgr's Name") to ("MgrsName") in the TABLE.

Does the QUERY "Probation Details_emailing" contain these Fields you are trying to access in your Recordset?
Show Just This Thread        Post Reply

Show Older Posts         Collapse All Topics


Post Your Comments or Subscribe
    If you would like to be notified of new posts on this forum,
    just enter your email address below. It will be kept private.
If you just want to subscribe to get email updates when this forum is updated, then enter your name and email address and check the Notify Me box below. If you would optionally like to add your comments below to be posted, they are welcome.
  Your Name:  Required
  Your Email:  NOT Public


Sorry about this step. It's just to keep the spam bots away:
  Verify: What is 9+7:
  Notify me when the this forum is updated
  Remember Me for my next comments
Please do not use this form for Customer Service inquiries! If you have questions about your account, shipping info, courses you've ordered, need passwords, etc. please use the Customer Service Center instead.

I value your comments. They will be displayed on this page (above). Your name will be displayed, but your email address will not be.
As always, I promise to never give away your personal information to anyone else, ever.

NOTE: If you don't leave your name and email address, DON'T expect a reply. I can't promise a personal reply to everyone who posts here. I TRY my best, but I cannot guarantee it. If you don't leave your real name and email address, I won't even bother. I usually just hit DELETE. -Richard



Visual Basicindex
Account Login
Online Theater
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Live Chat
Customer Support
WalkThru Tutorials
Consulting Services
About Us
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Gift CDs
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP