r/visualbasic • • Feb 17 '15

Attaching to and automating an existing IE instance is a pain. I wrote some functions to make it less of a pain.

Thumbnail
github.com
6 Upvotes

r/visualbasic • • Nov 03 '14

Is Visual Basic something a total beginner can learn?

6 Upvotes

Hi all. My husband, who is not a programmer but has some programming experience, is thinking about learning Visual Basic because of a potential new job opportunity. I am an absolute beginner when it comes to programming but I thought it might be more fun to learn together. Is this a good idea? Are there any tutorials you would recommend? Thank you!


r/visualbasic • • May 17 '14

How to create a Sudoku Solver, using Visual Basic 2010 Express part one

Thumbnail
youtube.com
6 Upvotes

r/visualbasic • • Mar 07 '14

For your pleasure: A generic XML serializer + deserializer

6 Upvotes

I see a lot of posts where people are trying to save/load classes to disk, with varying results. I tend to recommend looking at the XMLSerializer documentation, but they're limited in that they only work for one specific class. Coding the same thing over and over again is always stupid, so a long time ago I made a serializer/deserializer that works with anything you give it! Huzzah!

Load/Deserialize:

Public Function Load(Of T)(path As String, classToLoad As T) As T
    ' I had a specific reason for doing this, but i don't remember why. maybe it
    ' was related to not being able to call GetType() on a null object? oh well..    
    Dim tp = If(classToLoad Is Nothing, GetType(T), classToLoad.GetType())
    Dim stream As StreamReader
    Try
        Dim reader = New XmlSerializer(tp)
        stream = New StreamReader(path)
        classToLoad = CType(reader.Deserialize(stream), T)
    Catch ex As Exception
        ' write a message to the console, pop up a message box, whatever 
        classToLoad = Nothing
    Finally
        If stream IsNot Nothing Then
            stream.Close()
        End If
    End Try
    Return classToLoad
End Function

Save/Serialize:

Public Sub Save(Of T)(path As String, classToSave As T)
    Dim writer As New StreamWriter(path)
    Try
        Dim ser As New XmlSerializer(classToSave.GetType())
        ser.Serialize(writer, classToSave)
    Catch ex As Exception
        ' do the needful
    Finally
        If writer IsNot Nothing Then
            writer.Close()
        End If
    End Try
End Sub

Edit: Yes, I do know that the Try...Catch blocks are functionally equivalent to Using..., I just like the ability to inform the user of why it failed


r/visualbasic • • Apr 12 '13

I found a bug in VB: math class

Thumbnail
imgur.com
6 Upvotes

r/visualbasic • • Apr 03 '13

Classic Visual Basic’s end marked a key change in software development

Thumbnail
codeproject.com
6 Upvotes

r/visualbasic • • Feb 09 '13

Hidden Features of VB.Net -- Something for Everyone

Thumbnail
stackoverflow.com
6 Upvotes

r/visualbasic • • May 23 '12

Stubborn StreamReader

6 Upvotes

Hey guys,

I've got a bit of trouble here, this component of my code writes an integer to a text file on close and then writes it to an integer when the form loads.

The problem I'm having is that the "Process cannot access the file because it is being used by another process" error.

Now I've put it down to my load streamreader, even though I've included the streamreader.close() line it doesn't actually process this line. It only reads the line before it and proceeds to open the form.

Here's my code:


Private Sub Main_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

    Dim sw_QuoteNo As StreamWriter
    Dim sFileName As String
    Dim iRecords As Integer

    iRecords = lbxQuoteNumber.Items.Count
    sFileName = Application.StartupPath & "\QuoteEnd.txt"
    sw_QuoteNo = New StreamWriter(sFileName, True)

    If File.Exists(sFileName) Then
        sw_QuoteNo.WriteLine(iQuoteEnd)
    Else
        MsgBox("The file was not found.")
    End If

    sw_QuoteNo.Close()

End Sub

Private Sub frmQuoteSystem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim sr_QuoteNumber As StreamReader
    Dim sFileName As String
    Dim sLine As String

    sFileName = Application.StartupPath & "\QuoteEnd.txt"
    sr_QuoteNumber = New StreamReader(sFileName, True)

    iQuoteEnd = sr_QuoteNumber.ReadLine

    sr_QuoteNumber.Close()
End Sub


Obviously, one is the form load sub and the other is the closing sub.

Some clarity would be much appreciated, I've been working on this for far too long to no avail.

(I do have other streamreader/writers but they're triggered with a button)


r/visualbasic • • Feb 13 '12

Hidden Features of VB.NET

Thumbnail
stackoverflow.com
6 Upvotes

r/visualbasic • • Dec 18 '11

Welcome to the new r/VisualBasic!

6 Upvotes

I recently took over /r/visualbasic and /r/vbnet (though I figured that they could both be combined into one community since /r/vbnet was created as a result of a failed submission and had no submissions itself) and I'm hoping we can "revive" this reddit and have it expand into a more active/larger community than what it is now.

What I've done so far

  • added a header image

  • a bit of a theme (the navigation bar at the top of the reddit uses the same colour style as tabs in VB.NET's IDE) - I was working on a "full" reddit theme but the link colours clashed with the darker blue background so I've settled for just a coloured background (same as the VB.NET IDE's selected tabs) but I might try the "full" theme again later.

  • minor tweaks

  • rewrote the sidebar*

Regarding the sidebar

I'm not sure what to put in the sidebar - rules? If rules, what should be allowed and what shouldn't?

I'd appreciate any suggestions or feedback you have so that we can make this community better.

-Ordona


r/visualbasic • • Nov 18 '25

VB.NET Help Need someone to help me create an "Active Desktop" like a webpage. (Partically it is related to Visual basic)

Thumbnail reddit.com
5 Upvotes

r/visualbasic • • Aug 25 '25

Discord server for VB (.Net and COM)

Thumbnail discord.gg
5 Upvotes

r/visualbasic • • May 01 '25

VB Neural Net Library ca. 1992?

5 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 • • Sep 09 '24

App resizing on its own, looking for pointers

5 Upvotes

Hello.

Some premise:

  • There is a VB app made by someone, somewhere, at some point in time, which may or may not have been coded with feet

  • The app runs on an older Windows tablet with no apparent trouble

  • The app is now being run on a newer tablet with higher screen resolution

  • I have never touched VB in my life

What it does:

  • Upon loading a dxf file, the resulting graph is plotted over a background grid

What happens:

  • Upon loading the dxf file, the app resizes all by itself to a lower size

I am fully ignorant of any of VB's idiosyncrasies, I usually do C/C#/Web.

Any idea where to start looking? Relevant words to google/search in the code? Is this a normal thing to occur? Any questions I may answer to help?

Post is unflaired because I don't know the version. The files appear to be .vba .vb.

Thanks!


r/visualbasic • • Jun 06 '24

VB6 cant visualize dbgrid rows on windows 11 even if the data is loaded

5 Upvotes

Hi everyone,
as the title says i have a problem with my vb6 dbgrid, the data is loaded and when i click on the rows i can see the data on the below half of the program but i just cant visualize the rows. If i select another row the data below changes.
Does anyone have a clue on how to solve that? On windows 10 it work's fine


r/visualbasic • • May 12 '24

Help fix visual basic 6 not running properly in windows 10

5 Upvotes

I don't know if the title I have put is right but I needed this, I currently have a WinRar file that contains the setup, and VB98 and multiple other this from a source I will not say but it is a trusted source, I ran the VB 6 in the VB98 folder and I ran into these problems:

"DAO350.dll" is missing, and I fixed it by putting the dao file in the VB98 folder then this problem came next: Unexpected error; Quitting

And now im stuck, im currently making a project and im almost late for submission because the laptop that has the program is at my group mate's house but im far from him and he don't understand properly how to make the program so im in a dilemma. I acquired the WinRar file named "Visual Basic 6 Installer" on one of my friends that is from another group.

There is a setup.exe and I randomly guessed its License thing, and It about to install something in the laptop and Im guessing its Visual Studio files but im pretty scared because last time I did this is using another installer from the internet, and it resulted into corruption in the laptop and a massive expense for fixing it and my dad is pretty mad for it so im seeking guidance here. If someone is willing to check for it and help me resolve this so I can finally finish it, I will give them a link for it when they message me, But I will say that you must be cautious because even if I have scanned it multiple times for viruses and my friend installed it in his windows 10 (He does not even know how to install it because someone else installed it for him). Just message me and ill send the link for it but please tell me how to install it after you checked it yourself.


r/visualbasic • • Apr 30 '24

ComboBox Data from SQL Table

5 Upvotes

Hey all,

I have a SQL table as a Data Source in my Visual Basic 2022 program. I want one of the columns to populate a dropdown menu (ComboBox). I've looked on-line, but there are a mixed bag of answers it seems.

Is there a simple way to populate the ComboBox with one column's worth of data from my SQL table?

TIA


r/visualbasic • • Mar 12 '24

How to cleanly exit a VB.NET program?

5 Upvotes

Although I've been coding in VB.Net for years, I've never been able to cleanly exit, despite many attempts, and google searches.

For example, I have a simple, single form application. When somebody clicks the close button (the x on the top right of the window) I want the software to cleanly exit.

I have recently tried again with the below code. It runs and doesn't complain. But if I run the exe outside of visual studio, it remains in memory and have to kill it in the task manager.

Any advice would be greatly appreciated.

  Private Sub ProgramClosing() Handles MyBase.FormClosing

        Application.Exit()


    End Sub

r/visualbasic • • Jun 05 '23

Help with Print statement in MS Excel

5 Upvotes

I've already posted this in r/spreadsheets but I'm not sure if that was the best place to ask my question.

I'm trying to use print to write out a batch file, but it keeps cutting off the final quotation mark that I need. Apologies in advance for bad formatting, I barely ever use reddit, let alone post.

The core of my script is:

Sub test()
Application.DisplayAlerts = False
Dim filename As String
Dim commandline As String
filename = "C:\Users" & Environ("Username") & "\Desktop" & worksheets("Settings").Range("A10").Text
commandline = (Worksheets("Export").Range("A2").Text)
Workbooks.Add
ActiveWorkbook.SaveAs filename, FileFormat:=xlUnicodeText, Local:=True
ActiveWorkbook.Close
Open filename For Output As #1
Print #1, commandline & Chr$(34)
End Sub 

I've also tried using a string to define a quotation mark along the lines of

Dim quotes As String quotes = (Chr$(34)) 

as well as spamming the crap out of it, but it always cuts off the final quotes I need.

For reference, what I'm trying to write out is

start D:\Games\ArmA3\A3ServerNo1\arma3server_x64.exe -server -port=2302 -noPause -noSound -profiles=D:\Games\ArmA3\A3ServerNo1 -bepath -cfg=basic.cfg -loadMissionToMemory -config=server.cfg -autoInit -filePatching -name=Administrator  "-servermod=@CUP Terrains - Core;@CUP Terrains - CWA;@CUP Terrains - Maps;@CUP Terrains - Maps 2.0;@CBA_A3;@Advanced Rappelling;@Advanced Towing;@CUP Weapons;@CUP Vehicles;@CUP Units;" "-mod=@CUP Terrains - Core;@CUP Terrains - CWA;@CUP Terrains - Maps;@CUP Terrains - Maps 2.0;@CBA_A3;@Advanced Rappelling;@Advanced Towing;@CUP Weapons;@CUP Vehicles;@CUP Units;" 

The final quotation mark after CUP Units; is what keeps getting cut off

When I write the string value to a cell using something like

Sub test()
Dim commandline As String
commandline = (Worksheets("Export").Range("A2").Text)
Activesheet.Range("A3").value = commandline
End Sub 

It includes the final quote, that's what makes me think it's something to do with the print function, or the file type.

I've tried using xlTextWindows as well as xlTextPrinter, but they both do the same thing.

I hope this post wasn't a nightmare to read.

Any help from you guys is greatly appreciated


r/visualbasic • • May 20 '23

help ive been tryna install vb6.0 for a school project and this keeps showing up

Post image
5 Upvotes

r/visualbasic • • May 09 '23

I have very simple question that I couldn't make sense. Why do we have to put Textbox1.Text before "Hello"

Thumbnail
gallery
5 Upvotes

r/visualbasic • • Jan 26 '23

Working Code to Post a Tweet??? Tried Everything...

5 Upvotes

I have tried example after example off the internet, even to the point of asking ChatGPT to write code. Nothing works. Lots of the examples on Google are not v2 and there seems to be other issues with Oauth. I have also tried installing several Twitter Nuget packages and have failed at those working, usually 403 errors even though app appears to have write access. I have all the keys and tokens, elevated Twitter API account status, and "your project has essential access". Anybody have any working code I can try to see if the code is the problem or something else?


r/visualbasic • • Jan 12 '23

Problem open web link with process.start in visual studio 2022

5 Upvotes

Hi all
when I try to open a web link with Process.start it gives me an unhandled exception error ... can you explain why?

The instruction is this: Process.start("www.google.com")

Thank you


r/visualbasic • • Jan 08 '23

VB.NET Help [Newbie] How can I not include the " " when textbox is empty?

5 Upvotes

Hi, I'm very new to Visual Basic. I just created a simple Tool that would help me rename a document. Unfortunately, I can't find the right keyword search on how to do this.

First of all, I have a button that will combine all the textbox input into a underscored naming convention.

Once I clicked the "Copy Text", It will copy like this: NAME_XXXX_CREDITOR_DOC TYPE_DOC DATE_DATE RECEIVED

    Private Sub btnCombine_Click(sender As Object, e As EventArgs) Handles btnCombine.Click

        Dim name, accno, cred, doctype, docdate, daterec As String

        name = txtName.Text
        accno = txtAccNo.Text
        cred = txtCreditor.Text
        doctype = txtDocType.Text
        docdate = txtDocDate.Text
        daterec = txtDateRecieved.Text

        Clipboard.SetText(name & "_" & accno & "_" & cred & "_" & doctype & "_" & docdate & "_" & daterec)

    End Sub

My dilemma is there's a time when I don't really need all the textbox and I need to skip some. The problem is the underscore will still be on the result like this: NAME___DOC TYPE__DATEREC instead of: NAME_DOC TYPE_DATE REC. How can I skip those underscore if I'm not using their String?

I hope you can understand it and I will be grateful for any help. Thanks!


r/visualbasic • • Sep 19 '22

VB.NET Help How to pull values passed from SQL (MS SMS)

5 Upvotes

I'm building a webpage in Visual studio. I have SQL server sending three columns of data to my page via a stored procedure. Its calling names and email address. My web page has a drop down that shows the names, but I want to pass the associated email address to another line of code. How can I call the email address from the selected user name in the drop down.