Go Premium for a chance to win a PS4. Enter to Win

x

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,


I would like to create a button that will toggle the values of either true or false of all checkboxes within the entire row.

I have multiple rows of checkboxes which i use to calculate values

thanks
0
Concerto Cloud for Software Providers & ISVs
LVL 5
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Hi, do you have any shortcut for avoiding special characters in textbox?
im using this manual code:

Public Class Form1
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If TextBox1.ToString.Contains("`") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("~") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("!") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("@") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("#") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("$") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("%") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("^") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("*") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("&") Then

Open in new window

0
Hello Experts,
Our customer has several applications, a few of them developed more than 20 years ago in visual basic and visual fox
they work just fine so the customer is not interested in migrating although we are pushing him to do so... and probably soon
he will in invest in these...
for the time being we are still using a four applications developed 3 in vb6 and 1 in vfp
everything has been working ok until last weekend taht we upgraded to win 10
the older app seem not to be updating when working in the network as usually
and we are experiencing some corruption in the fox indexes...

Is there any parameter in win 10 that we can use to help this...
the customer may take this a a way to push him to invest right now
and that is not the idea.... the customer has to do it in his own time and understanding..

So i would really love to find a solution for this.

Best regards,
0
Hello, I would like to create a VBA in Outlook 2013 to move an email after reading the body of the email message with the following text:
_stopRequested= False
Files that don't exist: 0

Open in new window

Any thoughts ? Or better way to do this ?

Thanks for your help
0
Hi,
I get error

File name does exist

to line

Shell (Command0)

Open in new window


while Command0 is having value

rename "C:\cmp3g\CODECO_ERROR_a\CNESI_CNSNHEPI_20171108095055_958.ERR" "CNESI_CNSNHEPI_20171108095055_958.edi" 

Open in new window

Why?
0
I have a VB6 Application  and a PHP application on 2 different PCs

I want to take a PHP script  (attached) and run it within the Visual Basic Code

My first thought was that since the PHP Script feels like an HTML  file

there may be a  way  to run it with the Shell command

Can any one help out with this

I attach the PHP Script

Thanks

O.A.  Oluwole
index.php
0
Hi all.  

I currently have the following line of code to see if number entered is a valid one in my MasterCellDevices table:

            If DCount("connection", "MasterCellDevices", "[connection]='" & Me.txt_InvConnectionPhone & "'") > 0 Then

If it is a valid number I want to check to see if there is anything in the MasterCellDevices.ID field.  If there is, I want a msgbox to pop up saying that it is already assigned to a different location.  If it is null or empty I want it to update the field with the current ID.

I am struggling on how to figure out whether or not that field is empty or not.

Sorry if I didn't explain it enough, but I am new to coding and looking for help.

Thank you for your time and help.
0
Will C++ and VB6 continue to work in newest versions of Windows?
We have some old program written in  C++ and VB6 and want to prioritise upgrading them to .NET.
If a new version of Windows will make them obsolete overnight then upgrading them is a high priority.  Otherwise not.
A similar question arises if processors move from 64 bit to 128 bit.
0
In order to open a connection on my VB6 app, I use the following info:

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset


conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",1433;Network Library=DBMSSOCN;Initial Catalog= xxxxxxxx; User ID=xx;Password=xxxx"

However, if I was going to use Microsoft Azure SQL database, I will need to change this connection string.  They provide  ADO.NET, JDBC, ODBC and PHP connection strings.  None of those are similar to what I'm using now, so what changes would I have to make in order to make this connection work?  I'm guessing that ODBC would be the choice which looks like this:

Driver={ODBC Driver 13 for SQL Server};Server=tcp:xxxxxxx,1433;Database=xxxxx;Uid=xxxxxx;Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;


How would I structure this in VB6 to connect?
0
Hi Experts,

I have some tasks that currently users must do it manually in daily bases, however since this is prone to errors, the manager would like it should get automated done via code.

1- Look for specific file in default download folder that name starts with Tables_TodaysDate_LatestNumber.Zip (See attached).
2- Extract it to specific folder (C:\Application)
3- Delete old File C:\Application\Tables.MDB
4- Rename extracted file (something like Tables_2017-Oct-30_2230.mdb) to Tables.MDB

Would prefer it done either by calling some DOS commands from VBA or just using native VB functions if possible.

Thanks in advance.
Capture.PNG
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Greetings .VBS script guru's!

I'm trying to write a FOR loop that continually loops every 15 minutes (in the background) until the user clicks the "OK" button. If the user clicks the "cancel" button, then the VBS script will run in the backgroup and pop-up again every 15 minutes until the user clicks the "OK" button (which then performs an action). I've tried a DO, and WHILE and a FOR loop, without any success.

Any ideas how I could accomplish this?

Thank you so much for your expert assistance!

-Mac
0
I have a MYSQL database hosted on website
I want to create a standalone program to run on windows PC that will use the MYSQL database to display appropriate data
The standalone program must be able to run external programs that are on PC that the database refers to
Any suggestions on the approach, language etc would be welcome.
0
Dear experts, I create a daily task to start a powershell script as below, to delete some files but it did not work. The history show nothing special except 0x103

del C:\Test1\*
Remove-item C:\Test2\A\*

Open in new window


Please check and suggest. Many thanks in advance.
history.PNG
history1.PNG
0
I have written some MS VBA code to scan a document on my local scanner and save the resulting scan in a particular folder with a particular file name. It arrives there as a BMP file, which is unacceptably large in file size (typically 25 MB). I have a CutePDF and PDF Creator and MS Print To PDF as PDF printers to choose from, if needed, but I cannot figure out how to print the BMP file to them by using some effective VBA code.

So, using MS Access VBA, how do I select the BMP file, convert it to PDF and save it in the same folder with the same name (except with a PDF extension, of course)? When I do this manually I get a PDF of around 500 kb, which is much more acceptable in size.

The end result I need is for the user to place a document, like a tax file number application, on the scanner, click a button on the database and have the system scan the doc, file it in the employee's folder on the server with a name indicating that it is his or her tax file number application and then automatically convert the resulting BMP to PDF and finally to delete the BMP file to save space on the server.

I can do all of this except the actual conversion of the BMP to PDF. Can any one help me here? My environment is Win-10, Access 2016. Thanks
0
Hi Experts,

I have the following function
Function ViewPic()
'View Pic From DB
Dim OutFile As String
Dim strSql As String
If Len(Me.Signature & "") < 20 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
    
        Report_Report1.ScaleMode = 3
        
        For Each Value In Json("values")
         Report_Report1.Line (Value("lx"), Value("ly"))-(Value("mx"), Value("my")), vbRed
        
        Next Value

End Function

Open in new window

While in one database it runs file, when I copy that to another DB and run it (in report Detail format section event like in other DB), it gives me an error Object required in following line
        Set Json = JsonConverter.ParseJson(str)

Open in new window

1- I made sure it has all library references from the other DB
2- Also imported the general module JsonConverter that other DB had for this.
'Attribute VB_Name = "JsonConverter"
''
' VBA-JSON v2.2.3
' (c) Tim Hall - https://github.com/VBA-tools/VBA-JSON
'
' JSON Converter for VBA
'
' Errors:
' 10001 - JSON parse error
'
' @class JsonConverter
' @author tim.hall.engr@gmail.com
' @license MIT (http://www.opensource.org/licenses/mit-license.php)
'' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
'
' Based originally on vba-json (with extensive

Open in new window

0
Hello Experts

I have old Crystal Reports version 4.0 Pro developed by the ton and they are most of them called from old VB3 program and worked fine ever since.

Today one of my staff reported that they keep getting the Error 20500 Out of Memory on a specific report under specific criteria selected. They run Win 7 32 bits. We tried an other chap at the office and they got the same error too on the same report. Mind you all other reports works fine and this report is not memory hungry. What it does is when you launch the report from the VB program you get the preview window and the records starts rolling up to a point when you get this error. I ran it a couple of time to see if it is related to a specific record but NO it throw the error every time at a record count different.

I thought that maybe I should increase the MaxbufferSize of Jet in the registry under Jet 2x but this did not help, any clue here ???

I tried the same report on my machine Win 7 64 bits (under the Virtual Machine running XP) and the report ran fine with no error whatsoever.

I have been all day checking all about this error on the Net and have done all possible but can't find anything that fixes it.

The database used in the VB3 is MDB Access 1.0 or 1.1 or 2.0
0
This app written in VB.Net w/Visual Studio 2010) is executing a thirty-part function inside a background.worker (see Private Sub bgwKeyPad_DoWork) and is triggering a function that update a textblock container (see Private Function RetFunKey(resultkey As String) As String).

The execution of that RetFunKey results "Cross-thread operation not valid: Control 'txtkey1' accessed from a thread other than the thread it was created on."

How can I solve this problem? Thanks in advance.



Private Sub bgwKeyPad_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bgwKeyPad.DoWork
    .
    .
    Dim RetFunKey As New ClassPosCOM.POSCommunication.AsyncRetKeyPress(AddressOf Me.RetFunKey)
    pinOne = pinp.AsyncPinblockMessage(kpCom, tTarjetaSel, RetFunKey)
    .
    .
EndSub

Private Function RetFunKey(resultkey As String) As String
    '**************************************************
    '** resultkey = cantidad de asteriscos a dibujar
    '**************************************************
    txtkey1.Text = ""
    txtkey2.Text = ""
    txtkey3.Text = ""
    txtkey4.Text = ""
    Select Case Val(resultkey)
        Case 1
            txtkey1.Text = Chr(149)
        Case 2
            txtkey1.Text = Chr(149)
            txtkey2.Text = Chr(149)
        Case 3
            txtkey1.Text = Chr(149)
            txtkey2.Text = Chr(149)
            txtkey3.Text = Chr(149)
        Case 4
            txtkey1.Text = Chr(149)
         …
0
I need a script to press automatically OK every 2 min, see snapshot bellow and here the script i use, not working:

Set wshShell = CreateObject("WScript.Shell") 

Do 
    ret = wshShell.AppActivate("Remote Desktop Connection") 
    If ret = True Then 
        wshShell.SendKeys "{ENTER}" 
        Exit Do 
    End If 
    WScript.Sleep 500 
Loop 

Open in new window

error.JPG
0
Hi

I am looking for a VB script that would allow to type full name or users name in a search box that would run against certain LDAP groups (43 groups) to confirm if the user exists. If the user exists the output should be display on the screen and save in CSV file.

These 43 groups exists in AD (LDAP).

Thank you, M
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 5
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

I have a visual basic 6 form  with regular  buttons  ie
cmdAdd
cmdUpdate

My requirement is to allow different user  during login
to have a button have specific properties i want for that buttonand  for that user

What I have done is to create  a table   containing the following fields and  sample values see attached

When user "MASTER"   runs a form i call  runinvoices  I am able  to  read the table and set

string6 = runinvoices.cmdAdd.Enabled =  '1'

from the string  below

string6 = string2 & "." & string3 & "." & string4 & " = '" & Trim$(string5) & "'"

The problem i have is how do i get my form  to execute   runinvoices.cmdAdd.Enabled =  '1'

which would enable the cmdAdd  for this user

Another  User may have  runinvoices.cmdAdd.Enabled =  '0'

saying  disable the Add command button for the other  user

My question is:

Am I  doing the right thing to be able to have diffrent button properties react
differently  to different  users ??

If yes  how do i get the form during form load  to  recognise  the value  of  runinvoice.cmdAdd.Enabled = '1

If I can not get this to work how can i achieve  this functionality

Thanks  

Oluwole'
buttonproperties.PNG
0
Hi experts,

I have 2 questions on my app which I put at the bottom of this post.

I'm have a vb6 application. Yes you heard right a vb6 application.
I'm using sql server 2008.  I'm using the Employees table from the Northwind sql server database.
I'm learning to work with Recordsets.

I have a sql server stored procedure that looks as shown on this script:

USE [Northwind]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetEmployeeByID]
	-- parameter
	@EmployeeID as varchar(50)

AS
BEGIN					

SELECT [EmployeeID]
      ,[LastName]
      ,[FirstName]
FROM [Northwind].[dbo].[Employees]
WHERE [EmployeeID] = @EmployeeID 

END

GO

Open in new window


So when I execute this stored procedure like this on sql server management studio this is what the result set of the stored procedure looks like:

-- execute stored procedure and pass value of 2 to EmployeeID parameter
[Northwind].[dbo].[GetEmployeeByID] 2

Sql1.PNG
This is my code for my application. It works fine.

Option Explicit On
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As ADODB.Command
Dim strconnect As String
Dim VarEmployeeID As Long

Private Sub btnGetEmployee_Click()

    ' get value in EmployeeID textbox and save in variable
    VarEmployeeID = txtEmployeeID.Text

    'Call the Function - pass the argument to the function called GetAnswer
    'the result is stored in a variable called the answer
    Set rs = 

Open in new window

0
I have a timestamp field named quote_created for when the record was created. I also have a field named send_email in that record.

If the quote was created more than ten minutes ago AND send_email=1, I need to be notified via email. We have Exchange 2007.

Possible?
0
I'm using VB6 and sql server 2008.

I created a sample app using a function call.
It works fine and looks like this. Gets the some of some integers.
So the function i'm using returns an integer.

p1.PNG
This is my working code

Option Explicit

'declare variables
Dim varfirstnumber As Integer
Dim varsecondnumber As Integer
Dim varanswer As Integer
Dim theanswer As Integer

' the click event for the Get Sum textbox
Private Sub btnGetSum_Click()

    'get value of the 1st number text box and store it in a variable
    varfirstnumber = txtNumber1.Text

    'get value of the 2nd number text box and store it in a variable
    varsecondnumber = txtNumber2.Text

    ' sum numbers and store into variable
    'varanswer = varfirstnumber + varsecondnumber

    'Call the Function - pass the 2 arguments to the function called GetAnswer
    'the result is stored in a variable called the answer
    theanswer = GetAnswer(varfirstnumber, varsecondnumber)

    'display answer in label
    lblAnswerTextValue.Caption = theanswer

    'display answer in message box
    MsgBox "The answer is: " & theanswer
    Exit Sub

End Sub

' A function named FutureValue that requires 2 arguments
Private Function GetAnswer(Param1Number1 As Integer, Param2Number2 As Integer) As Integer

    GetAnswer = (Param1Number1 + Param2Number2)

End Function

' On Form Load event
Private Sub Form_Load()

    ' set label on form load - good
    'lblAnswerTextValue.Caption = 1

End Sub

Open in new window



In my example above the function returns an integer.

If I setup a function that calls a sql server stored procedure and than puts the table returned by the stored procedure into a record  set.

What it the syntax for my function so that it returns the recordset?

Then what is the syntaxt to call that function which is returning the recordset?

Anyone know?
0
I'm using vb6

I have a sql server stored procedure that returns a column called TestColumn1.
This column of data type integer.

in my vb6 code i'm getting the stored procedure result and putting it in a recordset.

Sometimes it contains numbers and the stored procedure result is like this:

TestColumn1
1
4
5
12

Other types it contains no records and the stored procedure result is just like this:

TestColumn1


Right now i have the if statement below.
If there are results display appropriate message. If there are no results display the other message
   
    ' my recordset
    Set myrs = cmd.Execute

 If Not myrs.EOF Then
        If myrs.Fields(0) Is Nothing Then
            MsgBox "You got no records."
        Else
            MsgBox "You got some records."
        End If
 End If
   


Right It works ok for when my stored procedure returns records.
But i'm not sure how to check for Null values and the syntax for that inside an if statement.

Anyone know the correct way to check for a null value with an if statement in vb6?
0
Experts,

Running into a problem with a legacy application.  Access 2003 runtime on Win 10 pro client PC's.

The method is failing with a run-time error 3275 "Unexpected error from external database driver (1)"

Example:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "[qryObjectName]", "C:\Folder\Filename.xls", True

Trouble began after MS Updates for the 2017-10 Cumulative Update for Windows 10 Version 1703 x64-based Systems (KB4041676)

Rolling back the update resolves the issue for now... but I'm looking for a practical fix.

Thanks in advance
Shawn
1

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.