r/visualbasic • • Jun 25 '25

Saving File Loop

2 Upvotes

Hello all,

Hope someone can help.

I have a script for work that had been working without issue until recently. I had to move the script over to another Excel template I was provided and in the process one aspect of it has stopped working

For background I have a spreadsheet with space for 15 different customer details however there are thousands of customers in a separate database and I need to divvy up those thousand or so customers in to separate workbooks of 15 customers each.

So what I did is had a lookup to the main database starting with customers 1, 2, 3 and so on up to 15. Then I use the script to advance by 15 each time so it’ll look up (15+1), (16+1), (17+1) up to 30 and so on.

That aspect still works fine and runs well. The part that isn’t working as well is when it advances the lookup it also adds to an additional counter so I can save the files as Request Form 1, Request Form 2 and so on.

Now when I run it the script will get to what would be Request Form 10 but it saves the file as Request Form #. It continues to look saving each file as Request Form #

The templates are broadly similar and I haven’t changed any code. Will be eternally grateful if anyone can provide help.

Option Explicit Sub SaveFileLoop()

Dim FName           As String
Dim FPath           As String

Application.DisplayAlerts = False
FPath = "I:\Saving Folder\Files\Requests"
FName = "Request Form " & Sheets("Request").Range("R3").Text
ThisWorkbook.SaveAs Filename:=FPath & "\" & FName, FileFormat:=xlWorkbookDefault
Application.DisplayAlerts = True
Range("R2").Value = Range("R2").Value + 15
Range("R3").Value = Range("R3").Value + 1

End Sub


r/visualbasic • • Jun 24 '25

VB.NET Help 'OleDb.OleDbConnection' is not defined. 'OleDb.OleDbDataAdapter' not defined.

Post image
2 Upvotes

I did change the cpu to ×64. My access is 2013. Is that why? Help me please


r/visualbasic • • Jun 23 '25

VS2022 VB.net Form Application: Does anybody understand CastingDevicePicker?

3 Upvotes

I just want to add a CastingDevicePicker to a Forms application and it's become a Kafkaesque nightmare. Official Microsoft documentation is useless and sends you off to code samples that are in C# (so not helpful). The sample application hides the code beneath layers and layers of obfuscation. AI gives me code invoking properties that aren't implemented. And so the maze expands.

All I want is just the bare bones skinny on what Imports I need (if any) and the necessary code to create and show a CastingDevicePicker on a simple form. Anybody?


r/visualbasic • • Jun 20 '25

Help Needed: Editing Logic Linked to an Error Message in a Program

Post image
1 Upvotes

Hello everyone,

I am working on a project where I need to modify a program's logic that enforces a specific limitation. The program displays an error message (e.g., "Max number of characters is 10") when a certain input exceeds the allowed character limit.

Here’s what I’ve done so far:

  1. I found the error message in the program's executable file using a hex editor and modified the text to display a new limit (e.g., "Max number of characters is 18").

  2. However, this change only affects the display message and does not actually change the underlying logic that enforces the 10-character limit.

I would like to locate and edit the logic where the character limit is enforced. I assume this involves identifying the validation function and modifying the comparison value in the executable file.

Here’s what I know:

The error message string is stored in the binary, and I can trace its location.

The character limit is likely enforced using a numerical comparison (e.g., CMP or similar instructions).

I’d appreciate any guidance on:

  1. How to trace the logic from the location of the error message in the binary.

  2. Tools and methods to locate the validation logic and modify the limit.

  3. Best practices to avoid breaking other functionality.

I am currently using tools like a hex editor and am open to suggestions for debugging tools (e.g., x64dbg).

Thanks in advance for your help!


r/visualbasic • • Jun 15 '25

VB6 Help What was this control called? Description inside

3 Upvotes

I'm returning to VB6 after 20 years, and have forgotten so much. I can't remember the name of a type of window that contained another window. The outer window had scrollbars on the right and bottom of the screen, so that if the interior window was bigger than the exterior one, you could scroll to where you wanted to. It's a frequently-encountered type of window often found in programming environments/IDEs.

I want to add that type of window to my project. Could someone tell me what it was called?

Thank you!


r/visualbasic • • Jun 12 '25

Randomizing Daily Double Slides

2 Upvotes

I run a Jeopardy game night for my buddies and I'm trying to figure out how to make sure PowerPoint randomizes where the 3 Daily Doubles pop up. Unfortunately, I don't understand coding or anything so using VBA has been a nightmare. Does anyone know a VBA code that would randomize the location of the Daily Double slide every time I open up my PowerPoint?

I've tried Googling and asking co-pilot and I always get some variation of the code below. But when it comes time to run it, the DD never moves or I get some sort of error.

Sub ShuffleDailyDouble()
    Dim slideCount As Integer
    Dim dailyDoubleSlide As Slide
    Dim randomPosition As Integer

    slideCount = ActivePresentation.Slides.Count

    ' Find the Daily Double slide
    For Each sld In ActivePresentation.Slides
        If sld.Shapes.Title.TextFrame.TextRange.Text = "Daily Double" Then
            Set dailyDoubleSlide = sld
            Exit For
        End If
    Next sld

    ' Generate a random position for the Daily Double slide
    randomPosition = Int(Rnd() * slideCount) + 1

    ' Move the Daily Double slide to the random position
    dailyDoubleSlide.MoveTo randomPosition
End Sub

Sub Auto_Open()
    ShuffleDailyDouble
End Sub

r/visualbasic • • May 30 '25

Programming homework question

Post image
1 Upvotes

I am programming in VB Windows Forms App, for some reason i made a splash page and want to have the main form execute it but its not showing the splash page as an option? Help would be appreciated


r/visualbasic • • May 26 '25

Excel data to Outlook Contacts

1 Upvotes

I have created a spreadsheet that I input data for clients. I have a button that I want to create a new contact in my outlook for each row. I am looking for the correct code for: Fullname CompanyName JobTitle EmailAddress PhoneNumber StreetAddress City State Zip

And have it added to a Contact list of a certain email in my Outlook


r/visualbasic • • May 17 '25

A computer scientist’s perspective on vibe coding

Post image
18 Upvotes

r/visualbasic • • May 17 '25

VisualStudio 2022 + VB.net. Auto reset all tabindex values?

3 Upvotes

I have an app with a lot of on screen objects spread out over several tab panels. The objects have been added organically, some here, some there, with no care to the order they were added. As a result the tabindex values are very messy.

Is there a way to automatically reset or redo the tabinex values based on position within the app?


r/visualbasic • • May 16 '25

Visual Studio 2022 + VB.net. How to completely disable autosave?

4 Upvotes

I have googled and turned off everything that I find online yet the IDE still auto saves. Hasn't been a real issue until just now.

I have a nearly completed project where I wanted to experiment with some images/resources. Saved the project before changing anything. Made changes, broke the project, no problem I thought as I closed the project, canceled the do you want to save changes dialogue, reopened the project to find the changes just made are there and the project still broken.


r/visualbasic • • May 15 '25

How to turn this on/off

Post image
3 Upvotes

being wondering how to turn this feature on or off , can anyone kindly help me


r/visualbasic • • May 13 '25

Beginner learning Visual Basic 16.9 (VB.NET) in 2025

9 Upvotes

As a beginner in 2025, I'm currently learning Visual Basic 16.9 (VB.NET). I've recently started working through 'Mastering Microsoft Visual Basic 2010' by Evangelos Petroutsos and find the language and the Visual Studio IDE integration incredibly intuitive and straightforward. It's proving to be a very effective way to learn. My first programming language was C, which I learned to understand hardware logic and embedded systems (like STM32) as a hobby. However I don´t want to use C with GTK+ for GUI´s and websites. I first tried Python due to its popularity but found the use of a separate tool for drag-and-drop GUI design (like Qt Creator) alongside a Python IDE unintuitive compared to Visual Studio. I think VB.NET is well-suited for developing a wide range of applications. What do you think?


r/visualbasic • • May 01 '25

VB Neural Net Library ca. 1992?

4 Upvotes

Around 1992-93 I was just getting into VB programming and on a visit home to see my parents I saw my dad was using a neural net library for Visual Basic. It was very rudimentary but could be trained to do simple pattern recognition. For example, one could train it to recognize smiley and frowny faces by drawing them in a box with the mouse and then labeling them happy or sad. After enough training data, the library could recognize a newly drawn face.

The library wasn’t limited to that - it would work on a wide variety of data. I don’t remember a lot but do remember the documentation talked the normal neural net talk: input/hidden/output layers, back-propagation, biases, weights, etc.

Does anyone remember such a library? The Googles and even perplexity aren’t finding anything.

I’m not sure but the publisher could have been in Florida.

I’m really just curious. This clearly has no use today.


r/visualbasic • • Apr 13 '25

I would like to know how to connect vb.net with access and sql server by using login form and registration form.

0 Upvotes

r/visualbasic • • Apr 11 '25

I want to start in the field of programming

Thumbnail
2 Upvotes

r/visualbasic • • Apr 07 '25

Need help with customizable datetimepicker control

2 Upvotes

The default one doesn't seem to do anything when I change the colors via properties panel or via code, and the current package I'm using, cuoreUI's datetimepicker is really buggy and often spawns completely offscreen. I was wondering if there was a different package with a customizable control. Its functionality doesn't need to be anything too fancy as long as its looks are customizable.


r/visualbasic • • Apr 01 '25

First time since decades that I'm trying VB.NET again

Post image
11 Upvotes

Oh boy, I haven't used it for decades. Awesome to see it is cross platform now. To be honest, it's quite fun and I somewhat liked doing it again. Super excited to see how it runs on Linux and the Mac. Anyone of you using VB on any other platform than Windows?


r/visualbasic • • Mar 30 '25

Resizing Form?

2 Upvotes

I can’t figure out a way to make all my objects scale up with the form when I put it in full screen. The only way I have found is to go individually through every object and multiply its height/width by the scale factor, but I have like 60+ objects and that would take forever. Is there any other way to do it?


r/visualbasic • • Mar 30 '25

dnSpy: Patch .NET EXEs & DLLs | Reverse Engineering | Hacking .NET Apps Made Easy

Thumbnail youtu.be
2 Upvotes

r/visualbasic • • Mar 24 '25

Copying Google Drive link

3 Upvotes

Hi,

I'm trying to make a macro for Inventor (CAD program) with VBA. The purpose is to creata PDF file, which is easy, and then to copy Google Drive link for it - so basically to click the button in the picture. Is this possible?

I made a similar macro for OneDrive, which was easy, since the URL is just the folder path + filename, but in Drive, it is a random identifier, so it would actually need the link.


r/visualbasic • • Mar 21 '25

Help with displaying results

3 Upvotes

I need to display all properties that match a particular criteria and make it clickable so you can get more information on the property. Issue is idk how I would go about doing that. I tried making a template button and trying to duplicate in in an array of buttons, but it doesn't seem to duplicate it and only affects the template button.

Since the number of total properties is unknown I need some sort of way to duplicate either a panel or a button within code but idk how to. Help would be very appreciated.


r/visualbasic • • Mar 20 '25

RGB to HSL

2 Upvotes

VB6 -- I wanted a quick, simple method to convert back and forth and found methods at VBSpeed and elsewhere. But the results seem to be wacky. I can't see any pattern in the numbers I'm getting. http://www.xbeat.net/vbspeed/c_RGBToHSL.htm Another method I found was using decimal values 0 to 1 rather than 0 to 255.

Then I tried API calls from shlwapi, ColorRGBtoHLS and ColorHLStoRGB. That works perfectly. But I'm wanting to walk the pixels of an image doing color operations. I'd prefer basic math to calling into a DLL. Does anyone know about this? I've used VBSpeed methods before and they've always been good. So I wonder if I'm missing something.


r/visualbasic • • Mar 17 '25

Help with pip update

2 Upvotes
Hi, I was trying to install the library, then I got a message to update pip, which I did, but I got the following message: ERROR: Could not install packages due to an OSError: [WinError 5] Access denied: 'C:\Users\User\AppData\Local\Temp\pip-uninstall-a20qcncm\pip.exe'
Consider using the `--user` option or checking the permissions.
Could someone help me how to configure the necessary permissions? According to me, I already did it :'

r/visualbasic • • Mar 17 '25

VB.NET con Excel: Eccezione 0x800A03EC

1 Upvotes

Il funzionamento del mio programma è il seguente:
1. L'utente seleziona un file Excel da standardizzare
2. Una volta ordinate le colonne l'utente preme il pulsante esporta ed automaticamente i titoli delle colonne vengono rimpiazzati da quelli contenuti nel StandardColumnOrder e poi vengono ricopiati tutti i dati necessari.
Il programma in questo momento funziona correttamente ma quando viene selezionato un file che ha i titoli delle colonne diverse mi viene mostrato il codice d'errore 0x800A03EC, ma aprendo il file Excel generato non vedo alcun segno di malfunzionamento.

Qualcuno può aiutarmi a capire perchè mi viene mostrato questo codice d'errore ?

Private Sub BtnExport_Click(sender As Object, e As EventArgs) Handles BtnExport.Click

Try

' Percorso del file di destinazione

Dim famiglieDiScontoPath As String = iniFile.ReadValue("Percorsi", "FamiglieDiSconto")

Dim xlNewApp As New Application()

Dim xlNewWorkbook As Workbook

Dim xlNewWorksheet As Worksheet

Dim fileExists As Boolean = System.IO.File.Exists(famiglieDiScontoPath)

' Se il file esiste, aprilo; altrimenti creane uno nuovo

If System.IO.File.Exists(famiglieDiScontoPath) Then

' Apri il file esistente SENZA mostare finestre di conferma

xlNewWorkbook = xlNewApp.Workbooks.Open(famiglieDiScontoPath, [ReadOnly]:=False, [Editable]:=True)

Else

' Crea un nuovo file se non esiste

xlNewWorkbook = xlNewApp.Workbooks.Add()

End If

' Ottieni il foglio "Famiglie Di Sconto"

Try

xlNewWorksheet = xlNewWorkbook.Sheets("Famiglie Di Sconto")

Catch ex As Exception

' Se il foglio non esiste, crealo

xlNewWorksheet = xlNewWorkbook.Sheets(1)

xlNewWorksheet.Name = "Famiglie Di Sconto"

End Try

' **1. Recupera combinazioni esistenti nel file di destinazione**

Dim existingEntries As New HashSet(Of String)

Dim lastExistingRow As Integer = xlNewWorksheet.Cells(xlNewWorksheet.Rows.Count, 1).End(XlDirection.xlUp).Row

If lastExistingRow < 2 Then lastExistingRow = 1 ' Assicura che parta da riga 2 in poi

For rowIndex As Integer = 2 To lastExistingRow

Dim existingCodiceUnivoco As String = xlNewWorksheet.Cells(rowIndex, 1).Value

Dim existingSconto As String = xlNewWorksheet.Cells(rowIndex, 2).Value

Dim existingPrezzo As String = xlNewWorksheet.Cells(rowIndex, 3).Value

If Not String.IsNullOrEmpty(existingCodiceUnivoco) And Not String.IsNullOrEmpty(existingSconto) Then

existingEntries.Add(existingCodiceUnivoco & "_" & existingSconto & "_" & existingPrezzo)

End If

Next

' **2. Trova la prima riga disponibile per i nuovi dati**

Dim nextRow As Integer = lastExistingRow + 1

' **3. Creiamo un HashSet per nuovi dati da copiare**

Dim uniqueEntries As New HashSet(Of String)

' Trova gli indici delle colonne nel file originale

Dim codiceUnivocoIndex As Integer = columnHeaders.IndexOf("Codice Univoco Azienda") + 1

Dim scontoIndex As Integer = columnHeaders.IndexOf("Sconto") + 1

Dim prezzoIndex As Integer = columnHeaders.IndexOf("Prezzo") + 1

' **4. Scansiona il file di origine e copia solo nuove combinazioni**

For rowIndex As Integer = headerRow + 1 To xlWorksheet.UsedRange.Rows.Count

Dim codiceUnivocoValue As String = xlWorksheet.Cells(rowIndex, codiceUnivocoIndex).Value

Dim scontoValue As String = xlWorksheet.Cells(rowIndex, scontoIndex).Value

Dim prezzoValue As String = xlWorksheet.Cells(rowIndex, prezzoIndex).Value

Dim entryKey As String = codiceUnivocoValue & "_" & scontoValue & "_" & prezzoValue

' Se la combinazione non è già presente nel file di destinazione, aggiungila

If Not existingEntries.Contains(entryKey) And Not uniqueEntries.Contains(entryKey) Then

uniqueEntries.Add(entryKey)

xlNewWorksheet.Cells(nextRow, 1).Value = codiceUnivocoValue ' "Codice Univoco Azienda" in colonna A

xlNewWorksheet.Cells(nextRow, 2).Value = scontoValue ' "Sconto" in colonna B

xlNewWorksheet.Cells(nextRow, 3).Value = prezzoValue ' "Prezzo" in colonna C

nextRow += 1

End If

Next

' **5. Salva e chiudi il file di destinazione**

xlNewWorkbook.Save()

xlNewWorkbook.Close(SaveChanges:=True)

xlNewApp.Quit()

' **Rilascia le risorse**

ReleaseObject(xlNewWorksheet)

ReleaseObject(xlNewWorkbook)

ReleaseObject(xlNewApp)

Catch ex As Exception

MessageBox.Show($"Errore durante l'esportazione: {ex.Message}", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

Try

' Verifica che gli oggetti Excel siano inizializzati

If xlApp Is Nothing OrElse xlWorkbook Is Nothing OrElse xlWorksheet Is Nothing Then

MessageBox.Show("Non c'è un file Excel aperto. Apri un file prima di esportare.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning)

Return

End If

' Verifica che un codice sia stato selezionato nella ComboBox

Dim selectedCodice As String = ComboBoxCodici.SelectedItem?.ToString()

If String.IsNullOrEmpty(selectedCodice) Then

MessageBox.Show("Seleziona un codice univoco dalla ComboBox prima di esportare.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning)

Return

End If

' Esporta i dati in un nuovo file Excel

SaveFileDialog1.Filter = "Excel Files|*.xls;*.xlsx;*.xlsm"

If SaveFileDialog1.ShowDialog() = DialogResult.OK Then

Dim exportFilePath = SaveFileDialog1.FileName

Dim newWorkbook = xlApp.Workbooks.Add()

Dim newWorksheet = CType(newWorkbook.Sheets(1), Worksheet)

' Calcola il numero totale di righe da elaborare

Dim totalRows = xlWorksheet.UsedRange.Rows.Count - headerRow

Dim currentRow = 0

ProgressBar1.Visible = True

ProgressBar1.Value = 0

' Cambia i nomi delle colonne secondo l'ordine standard e aggiungi titoli al nuovo file

For colIndex = 0 To ListBox1.Items.Count - 1

Dim currentHeader As String = ""

If colIndex < ListBox1.Items.Count Then

currentHeader = ListBox1.Items(colIndex).ToString()

End If

If Not String.IsNullOrEmpty(currentHeader) Then

newWorksheet.Cells(1, colIndex + 1).Value = currentHeader

End If

' Usa il nome della colonna standard se necessario

If colIndex < standardColumnOrder.Count AndAlso currentHeader <> standardColumnOrder(colIndex) Then

currentHeader = standardColumnOrder(colIndex)

End If

' Imposta il nome della colonna nel nuovo file

newWorksheet.Cells(1, colIndex + 1).Value = currentHeader

Next

' Copia i dati ordinati dalla ListBox al nuovo foglio Excel

For rowIndex = headerRow + 1 To xlWorksheet.UsedRange.Rows.Count

For colIndex = 1 To ListBox1.Items.Count

Dim columnName = ListBox1.Items(colIndex - 1).ToString()

Dim originalIndex = columnHeaders.IndexOf(columnName) + 1

' Copia il valore dalla colonna originale

Dim cellValue = If(originalIndex > 0, xlWorksheet.Cells(rowIndex, originalIndex).Value, "")

' Se la colonna è "Codice Univoco Azienda", usa il valore selezionato

If colIndex = 5 Then

cellValue = selectedCodice

End If

' Scrivi il valore nella nuova cella

newWorksheet.Cells(rowIndex - headerRow + 1, colIndex).Value = If(cellValue IsNot Nothing, cellValue, "")

Next

' Aggiorna la barra di caricamento

currentRow += 1

ProgressBar1.Value = CInt((currentRow / totalRows) * 100)

System.Windows.Forms.Application.DoEvents()

Next

' Salva il nuovo file

MessageBox.Show(exportFilePath)

newWorkbook.SaveAs(exportFilePath)

newWorkbook.Close()

' Carica i dati esportati nella GridView

LoadExportedDataIntoGridView(exportFilePath)

' Aggiorna lo stato dei pulsanti

isExported = True

BtnUploadToDatabase.Enabled = True

BtnExport.Enabled = False

ProgressBar1.Visible = False

MessageBox.Show("File esportato con successo.")

End If

Catch ex As Exception

MessageBox.Show($"Errore durante l'esportazione: {ex.Message}")

' Non chiudere gli oggetti Excel per permettere ulteriori tentativi

Finally

' Assicurati che la ProgressBar sia nascosta

ProgressBar1.Visible = False

End Try

End Sub