r/visualbasic • • Aug 27 '22

What is the latest version of VB?

5 Upvotes

Hello. I was a basic developer for years using VB6 as a hobbyist. I'm a bit older now, and would like to get back into it. What is the latest version of VB and where is the best place to download it? Thanks!


r/visualbasic • • Jul 14 '22

Help Converting VBA Code to VB

5 Upvotes

Hello, I have some VBA code I wrote to get all bullet point text in a Word document and I would like to use this within a code stage in Blue Prism to get all bullet point text within a text variable or preferably, a collection variable. The VBA code runs fine within Word, but I'm having trouble converting the code into VB to work within Blue Prism. 

Here is  the VBA code:

Dim Para As Paragraph
For Each Para In ActiveDocument.Paragraphs
       If Para.Range.ListFormat.ListType = wdListBullet Then
       MsgBox Para.Range
End If
Next Para

The main issue I seem to be running across is "paragraph" is not a valid data type in Blue Prism/VB that can be stored in a text or collection variable. So I'm a bit stuck on how to handle this. Also, I know that "wdListBullet" corresponds to a value of 2 for its enumeration, so I believe the value 2 needs to be used instead of "wdListBullet" within the code stage. Any help would be greatly appreciated. Sorry if this is super basic (no pun intended) but I have pretty much zero experience with VBA/VB.

Thank you!


r/visualbasic • • Jun 22 '22

having trouble understanding the new "method chaining" syntax

5 Upvotes

I have been using a .NET command line parsing library for a while, and their latest version of the library has changed the way it's called to using a much more confusing (to me) style of syntax that I've never used before. I would greatly appreciate if someone can point me to a resource that explains how to understand this syntax, or if you can explain it here, that would be helpful too.

The URL of the library is at https://github.com/commandlineparser/commandline. This project page has samples for VB.Net, along with other languages too.

An example of what I'm confused about is that to parse the command line arguments, I used to just have to make a simple call as follows:

CommandLine.Parser.Default.ParseArguments(args, Options)

where args is the array passed in to Main() and Options is an instance of the class with all the command line switches I had set up. The Options instance is populated based on the args values. In the new version of the library, that call now looks like this:

CommandLine.Parser.Default.ParseArguments(Of Options)(args) _
.WithParsed(Function(opts As Options) RunOptionsAndReturnExitCode(opts)) _
.WithNotParsed(Function(errs As IEnumerable(Of [Error])) 1)

I do not understand what is going on with all these multiple chained calls and sequences of parameters with functions in the parameters.

Any help would be most appreciated.

Thanks.


r/visualbasic • • Apr 21 '22

How to synchronize two CSV files from different computers?

5 Upvotes

I made a billing and inventory app to my small shop.
Everything is stored in a CSV file. (Sku, EAN, Price, Stock)
When i make an invoice, it rewrites the CSV with the new data.

Now it would be great, if we could make invoices on two computers at the same time.
How could we synchronize the data of the two CSV files?


r/visualbasic • • Feb 21 '22

Why does this keep happening when I'm doing codes?

Post image
5 Upvotes

r/visualbasic • • Feb 03 '22

I know nothing about VB but have a question about something for work I am trying to have done.

5 Upvotes

I hope this kind of post is ok! I am just looking for some advice I guess. Here's my situation.

I am trying to find a way to take data from an excel spreadsheet (text and numbers depending on the field) and use it to populate fields in a PDF form. I've done some research and know there is a way to do a one-off of this however, I will have about 8000 lines of information that will need to be populated into 8000 individual forms. Apparently there is a way to build something with VB to do this.

Does that make sense?

What sort of lift would this be for someone who knows VB? Has anyone ever done something like this? Is it finicky? I just really don't want my staff to have to individually populate 8000 forms if I can avoid it.


r/visualbasic • • Feb 01 '22

VB.NET Help I need Help - Using variable across forms (vb windows app.Net framework)

5 Upvotes

I'm trying to store the users input on one form then use the same variable (call it) on another form. I'm having trouble doing this and I've been searching it up for hours but I'm still confused. Basically I'm trying to do when someone clicks a button on the 1st form it should store the input (depending on which button) into a variable. Once they click the button it should take them to the next form and depending on their input from the last form it should go to different subs to change stuff.

In short - how to use a variable across multiple forms? please explain as simple as possible for me to understand.


r/visualbasic • • Jan 30 '22

Need some help

5 Upvotes

Hi! So I am making a 2d racing game. I have player controls ready but I have no idea how to make an AI to travel around the track. What are the basics to get it moving in a predetermined order?

Thank you.


r/visualbasic • • Jan 15 '22

VBScript Randomizing font of each character in a Microsoft Word document

5 Upvotes

Hello.

I want to randomize font of each character in a word document. I've tried to run this code from Developer (Ribbon)->Visual Basic but it gave me this error: "Invalid procedure name"

I want to create 4 different fonts with my handwriting to do some variation and write an essay in MS Word, then distort every page in a Photoshop template to appear handwritten

Thank you for your time.

I am open to any advice.

---------------------------------------

This is my script:

Set objWord = CreateObject(“Word.Application”)

objWord.Visible = True

Set objDoc = objWord.Documents.Open(“C:\Users\Razvan\Desktop\Stefan.docx”)

Set objRandom = CreateObject(“System.Random”)

intLow = 1

intHigh = 5

Set objRange = objDoc.Range()

Set colCharacters = objRange.Characters

For Each strCharacter in colCharacters

intRandom = objRandom.Next_2(intLow,intHigh)

Select Case intRandom

Case 1 strCharacter.Font.Name = “Arial”

Case 2 strCharacter.Font.Name = “Times New Roman”

Case 3 strCharacter.Font.Name = “Courier New”

Case 4 strCharacter.Font.Name = “Forte”

End Select

Next

---------------------------------------


r/visualbasic • • Jan 12 '22

Programming project

5 Upvotes

I have a programming project and i need to take dates from a database and display them in a calendar +2 (so if it was a Friday, it would highlight Friday, Saturday and sunday) on visual studio using the visual basic coding language. Any idea on how i could grab the dates from the database and display them in a calendar which highlights the date + the next two dates? I should also mention that im (trying) using OLEdb to connect my database to access


r/visualbasic • • Dec 03 '21

How to put data into listview on a different form

5 Upvotes

I have a program where I want to make some sort of kiosk, like, McDonald’s kiosk.

At the moment i have 3 forms:- Form1 allows the user to order food. There is also a button to confirm all the food they have ordered. Form2 allows the user to confirm an individual order, and add quantity of the individual order. After the user confirms the individual order, form1 will show again. Form3 allows the user to see all the orders that have been ordered, by displaying them on a listview.

My problem comes when I want to add the individual orders onto the listview.

Supposedly, the data from form2 should show up on form3, but for some reason, the listview can only display one individual order at a time.

So the question for me right now is, how can i transfer all individual orders from form2 and send them to the listview on form3?


r/visualbasic • • Nov 01 '21

VB.NET Help Cuts Off Form and listbox even when I attempt to resize it in the designer file

5 Upvotes

Adjusting it in the GUI didn't work, adjusting it in properties didn't work, and even when I went to the designer file to set the size that way it still didn't work. It cuts off the display of the form and the listbox and the groupbox containing the listbox.


r/visualbasic • • Oct 30 '21

Hi!! I need your help!!

5 Upvotes

Hi everyone!! I downloaded the VB6 and I have to do a work to get a job, I have to create to database in Mysql and connect to VB6, I have to do the table and the save, delete and update buttons to display the table of the database, do you know any tutorial on how to make a base and connect it to save the information through vb6 and mysql, because I have been looking for days on youtube and tutorial pages and I do not get anything, please I need your help, if I get that job I will receive a training to be able to work, Please I really need your help.


r/visualbasic • • Oct 07 '21

Receive SMS vb.net application

5 Upvotes

I'm looking for some direction...I'd like to receive text messages in my desktop application. I can send using the Twilio library in NuGet. However, for the life of me, i have no clue how to receive messages as as far as I can tell, you have to use ASP.net and it would have to be exposed to the internet. Is there a API I could use or use something like http listener? Just need some direction.


r/visualbasic • • Sep 10 '21

VB.NET Help Zero References to Sub

5 Upvotes

I am very new to Visual Basic and am finding that my code is not being referenced in the designer view at all. I am trying to get it to change the forecolor when i press tab then move to the next box, simulating a traffic light. I am almost certain it's not quite right but I cant fix it without being able to refence the code. Any help would be appreciated.

https://imgur.com/a/B0Pjhci

http://imgur.com/a/5Od4wZl


r/visualbasic • • Jun 17 '21

VB.NET Help My Exe won't open (Visual Studio 20109, Windows 10)

5 Upvotes

I build my program, everything works when I run it in the Debugger, everything is perfect.

I build the project. I go to the folder and I move the EXE to my desktop. I click it. There is a wait cursor, and then nothing happens. I rebuild. Same thing. Nothing.

Other programs don't suffer this problem. What could cause a program to run in the debugger but not as an exe?


r/visualbasic • • Jun 05 '21

VB.NET Help How would I create a Find and Replace system?

5 Upvotes

I would like to create a sort of hardcoded "Find & Replace" system. Currently in an app I have, all items loaded in a list (items are folder names) will display in a ComboBox. A couple of the names are not accurate, because they contain illegal characters, or characters not allowed as folder names. Therefore, I would like create either a two-dimensional list or array, I'm not sure which. The first column would basically be "Find what" and the second column would be "replace with". What's the best way to create a system that will do this?

See the table for sample data.

Find WhatReplace With
First-NameFirst/Name
Second- NameSecond: Name

As you can see, any time there is an illegal character, it replaces it with a dash, thus just searching for the dash and replacing it with the same character each time would not work.

I can probably figure out how to implement it, myself, once I know the best way to define it.


r/visualbasic • • Jun 01 '21

Tips & Tricks Art of Code : Pure Function

5 Upvotes

Pure function is concept from functional paradigm but it very useful when you adapt it to your code, it's about create a function with sufficiently argument(not use other variant then its method arguments), any change of value while process this method is limit to method argument only and always get the same result when give the same argument, it's make pure function very transparency and no side effect on run.

Example

Function add(A As Integer, B As Integer) As Integer
    Return A + B
End Function

It look too simple, right ? yet when you adapt to your code it become very hard to keep it pure like an example because OOP is very opposite of pure function, you don't know what's change within an object when you invoke its instance method.

List.Add(5)

It hard to tell what's happen or change within List when you look at OOP object, without source you can only trust it name and document what it does, you never know what will be a trigger to cause an error from it.

Array(0) = 5

This one look fine, right ? but only reason you feel it should be fine is its name suggest it's an array type which you know and trust it going to assist value 5 to position index 0 of array data without do any extra process but if it's not an array type, do you still trust it ? but whatever you trust it or not, you might be have no choice but to deal with it.

So how should we adapt pure function concept ?

  • It should be static method.

  • It should accept value type argument by value only.

  • It should return result of process from its arguments.

  • Constant is acceptable.

  • You maybe use local variant if you don't too serious about pure function and transparency but it better to avoid to do it.

Most easy way to adapt pure function is overload operator of structure, it's static method with ByVal argument only.

    Function [then](Of T)(ByRef Input As T, Update As T) As T
        [then] = Input
        Input = Update
    End Function

    Function greatest_common_divisor(A As Long, B As Long) As Long
        If A = 0 Or B = 0 Then Return 1

        While B <> 0
            B = A.then(B) Mod B
        End While

        Return A
    End Function
    
    Public Structure fraction
        Public ReadOnly top, low As Long

        Sub New(Top As Long, Low As Long)
            Dim N = greatest_common_divisor(Top, Low)
            Me.top = Top / N
            Me.low = Low / N
        End Sub
        
        Public Shared Operator *(A As fraction, B As Long) As fraction
            Return New fraction(A.top * B, A.low)
        End Operator
        
        Public Shared Operator /(A As fraction, B As Long) As fraction
            Return New fraction(A.top, A.low * B)
        End Operator
        
        Public Shared Operator +(A As fraction, B As Long) As fraction
            Return New fraction(A.top + B * A.low, A.low)
        End Operator
        
        Public Shared Operator -(A As fraction, B As Long) As fraction
            Return New fraction(A.top - B * A.low, A.low)
        End Operator

        
        Public Shared Operator *(A As fraction, B As fraction) As fraction
            Return New fraction(A.top * B.top, A.low * B.low)
        End Operator
        
        Public Shared Operator /(A As fraction, B As fraction) As fraction
            Return New fraction(A.top / B.top, A.low / B.low)
        End Operator
        
        Public Shared Operator +(A As fraction, B As fraction) As fraction
            Return If(A.low = B.low,
                     New fraction(A.top + B.top, A.low),
                     New fraction(A.top * B.low + B.top * A.low, A.low * B.low))
        End Operator
        
        Public Shared Operator -(A As fraction, B As fraction) As fraction
            Return If(A.low = B.low,
                     New fraction(A.top - B.top, A.low),
                     New fraction(A.top * B.low - B.top * A.low, A.low * B.low))
        End Operator
    End Structure

update - 1 : fixed missing [then] extension, rename gcd method to greatest_common_divisor and int to Long


r/visualbasic • • May 21 '21

Help displaying html email using mailkit

5 Upvotes

I've been working on an email client to connect to IMAP servers and so far have been successful getting a connection and displaying the emails in my inbox. I'd like to display emails using a web view 2 and have been looking at the documentation for 2 days straight now and have been unable to translate the C# code. So far, I've gotten connection, authentication and fetching and displaying the list of emails in my inbox in a list box.

Here is my code so far:

Imports System
Imports MimeKit
Imports MailKit
Imports MailKit.Net.Imap
Imports MailKit.Security
Imports MailKit.Search
Imports System.Threading
Public Class ReceiveEmails
    Dim HasAttachment As Boolean = False
    Dim aryAttachments() As String
    Private Sub btnConnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
        'Dim connectThread As New Thread(AddressOf Login)
        'connectThread.Start()
        BackgroundWorker1.RunWorkerAsync()

    End Sub
    Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
        Me.Hide()
    End Sub
    Private Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        'normally a thread or background worker cannot update the UI, but the line below is a cheap way to accomplish this task
        'not the ideal way to update the UI apparently, but it works
        CheckForIllegalCrossThreadCalls = False

        Dim username As String = txtAccount.Text.ToString
        Dim password As String = txtPassword.Text
        Dim imapServerName As String = cmbServer.SelectedItem

        Dim imapServer As New ImapClient(New ProtocolLogger("imap.log"))
        Dim i As Integer = 0

        imapServer.Connect(imapServerName, 993, SecureSocketOptions.SslOnConnect)
        imapServer.Authenticate(username, password)
        imapServer.Inbox.Open(FolderAccess.ReadOnly)

        Dim emailMessage = imapServer.Inbox.GetMessage(i)

        For count As Integer = 0 To imapServer.Inbox.Count - 1
            emailMessage = imapServer.Inbox.GetMessage(count)
            'email subjects get listed in a list box
            listEmails.Items.Add(emailMessage.Subject)
        Next

        Dim query = SearchQuery.SubjectContains("")
        Dim uids = imapServer.Inbox.Search(query)

        Dim items = imapServer.Inbox.Fetch(uids, MessageSummaryItems.UniqueId)

    End Sub
End Class

I want the background worker to fetch an email based on the list box's selected index, format any html and display it in the web view.


r/visualbasic • • May 17 '21

VB.NET Help How to use array.Sort()

5 Upvotes

So for a school project I have to add a sub where integers inside a text file would be converted into an array and then sorted in descending order. I managed to read the text file and output that, but if I use array.Sort(arrayText) nothing happens. Please could I have some help.

Code:

Sub scores()

fileReader = My.Computer.FileSystem.OpenTextFileReader("scores.txt")

Dim outPutString As String

outPutString = fileReader.ReadToEnd

Dim arrayText() As String = Split(outPutString, Chr(13))

Array.Sort(arrayText)

Array.Reverse(arrayText)

For Each value As String In arrayText

Console.WriteLine(value)

Next

Console.ReadLine()

End Sub


r/visualbasic • • Apr 17 '21

Can anyone make sense of this error? I’m following the books directions on how to create a 2 form program but anytime I run it I get this.

Post image
5 Upvotes

r/visualbasic • • Apr 15 '21

VB6 windows behaving strangely

5 Upvotes

Hi, we have a developer using a notebook with 2 attached monitors. On the notebook screen VB6 works normally, but if he uses it on either external monitor the window management goes weird. If he uses the search dialog, the code windows switch to cascading view and the window he started the search from closes.

Is this a known problem with some win10 drivers or something to do with the resolution or win10 scaling? I have not seen VB6 behave like this before.


r/visualbasic • • Apr 11 '21

VB.NET Help How to create an installer/setup file for your project - quick video - feedback welcome!

Thumbnail
youtube.com
5 Upvotes

r/visualbasic • • Mar 27 '21

VB.NET Help Word not properly closing

5 Upvotes

Hi there,

My code opens 2 Word documents, edits them and then saves them. They are in their own seperarate variables. However only one closes succesfully, the other one does not despite having identical code.

This is the code for the first one:

'Save and close the document.
        objWordApp.Documents.Item(1).Save()
        objWordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
        objWordApp.Quit()
        objWordApp = Nothing
        objDoc = Nothing

And the code for the second one:

objWordApp2.Documents.Item(1).Save()
objWordApp2.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
objWordApp2.Quit()
objWordApp2 = Nothing
objDoc2 = Nothing

As you can see they are both separate. Very frustrating because it will keep the program open despite closing and won't update things in other forms properly.

What am I supposed to do here?

Update:

 Dim objWordApp2 As New Word.Application
        objWordApp2 = New Word.Application
        Dim objDoc2 As New Word.Document
Dim appDataPadPBFile As String = appDataPadBT & "\template.docx"
        Dim appDataPadPBBNew As String = PakBonFolder & time.ToString(format) & " pakbon.docx"
        Dim PBFileNew As String = time.ToString(format) & " pakbon.docx"

        My.Computer.FileSystem.CopyFile(
    appDataPadPBFile,
    appDataPadPBBNew)

        objWordApp2.Documents.Open(appDataPadPBBNew)
        objDoc2 = objWordApp2.ActiveDocument

This is the code I use to assign the application and document. It's the same as the first Word one but with different variables. In case anyone asks how I know that the first one does close, it is because it does not appear in task manager after the code it closes. Checked with breakpoint


r/visualbasic • • Mar 19 '21

I need a command to search and find a value from a table.

5 Upvotes

So here's the situation: There's a 3x3 table with different numerical values in them. I need a command to, given a row and a line, extract the value located in the cell. Something like:

abc
def
ghi

i = ComboBox1_selectedIndex
j = ComboBox2_selectedIndex

Value = {i, j}

Since it's only a 3x3 table, I thought of making endless lines of If/Else If, but this idea doesn't sound elegant to me at all.

(I also don't know exactly HOW to add said table to my code. *Chuckles.* I'm in danger.)