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.


r/visualbasic • • Aug 15 '22

VB6 Help Courses for visual basic

5 Upvotes

Any free courses to learn visual basic not for beginners. Learn to intermediate levels


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 • • May 19 '22

VB.NET Help 2021 Advent of Code Challenge - Day 3 VB.NET solution

5 Upvotes

Solved - Revisions in comments

Hey, today I found the site Advent of Code and since I'm a still a newbie, I started to attempt the 2021 coding challenege. A description of what exactly the AoC challeneg is can be found in the link I provided.

Anyways, I thought i completed day 3 ,but when I submitted my answer it keeps telling me that it's wrong. I was hoping someone could crituque my logic, to see if my logic is failing.

Public Class Form1

Private Sub     btnDiagnosticReport_Click(sender As Object, e As EventArgs) Handles btnDiagnosticReport.Click

    Dim sr As StreamReader = New StreamReader("BinaryDiagnostics.txt") ' i shorten the name of the filepath for the sake of this post for privacy and readabilty

    Dim DiagnosticsReport As String

    Do Until sr.EndOfStream
        DiagnosticsReport = DiagnosticsReport & sr.ReadLine & Environment.NewLine
    Loop

    Dim BinaryDiagnosticReportArray = Split(DiagnosticsReport, vbCrLf).ToList

    Dim ZeroCount As Integer = 0
    Dim ZeroChar As String = "0"

    Dim OneCount As Integer = 0
    Dim OneChar As String = "1"

    Dim gammarate As String = ""
    Dim StringIndex As Integer = 11

    For i = 0 To 11
        For Each strng As String In BinaryDiagnosticReportArray
            For Each c As Char In strng
                If StringIndex >= 0 Then
                    If strng.Substring(StringIndex, 1) = ZeroChar Then
                        ZeroCount += 1
                        Exit For
                    ElseIf strng.Substring(StringIndex, 1) = OneChar Then
                        OneCount += 1
                        Exit For
                    Else
                        Exit For
                    End If
                End If
            Next

        Next
        If ZeroCount > OneCount Then
            gammarate = gammarate + ZeroChar
        ElseIf OneCount > ZeroCount Then
            gammarate = gammarate + OneChar
        Else
            ' ignore this reddit
            ' may need additonal logic
            ' figure out later
        End If
        StringIndex -= 1
        ZeroCount = 0
        OneCount = 0
    Next
    GammaRateLabel.Text = "Gamma Rate: " & gammarate
    EpsilionRateLabel.Text = "Epsilion Rate : " & StrReverse(gammarate)
End Sub
End Class

The "Binary Diagnostic" text file contains 1,000 different binary numbers that are 11 digits each.

The challenge requires that the answer be submitted in decimal foramt. I am using an online converter for that because

1.) i dont know how to do that and 2.) its not part of the challenge to do so.

Again, if the logic looks fine, then i know there is a problem with my dataset


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 • • Apr 15 '22

quite new to VB but I have a question...

5 Upvotes

If for example as user inputs a value (string) and they put a space at the beginning, eg " John"

How can this be removed in VB.net?

Thanks


r/visualbasic • • Apr 10 '22

VB.NET Help How to check if a specific image is in a picturebox? VB.Net 2022

5 Upvotes

Hello guys. VB. Net Noob here, I was wondering how you would check if a picturebox has a specific image. Basically, I am trying to create a 'Snap!' game, where random images load onto a picturebox, and then the picture is checked, and the name of the image is displayed onto a label. Here is my code so far

However, this doesn't work. I've posted for help on StackOverflow, and the people who are helping on there are telling me that I need to use a Random object to pick a name from this array, store that value and then get the resource image with that name and use it to set it for lblDisplay.

What does this mean, if anyone could help me I would really appreciate it, thanks.


r/visualbasic • • Mar 04 '22

VB.NET Help How to check if clients are online without holding up the application

5 Upvotes

Hi all,

I have a simple application that loads a list of windows clients from active directory into a list view control. What I want to do is ping them to check if they are online or not, I'm currently using the following function for that:

Public Function ClientOnline(ByVal sHostName As String) As Boolean
    Try
    If My.Computer.Network.Ping(sHostName) Then
        ClientOnline = True
    Else
        ClientOnline = False
    End If
    Catch
        ClientOnline = False
    End Try
End Function

The issue I'm having is that this locks up the application whilst all the clients are pinged. I'm looking for help in moving this ping request into it's own process that doesn't lock up the main application. Ideally I would like to be able to control how many of these processes are running at once so I don't just fire off a large number of them if there are 100+ clients on the network.

Any help is greatly appreciated.

Thanks


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 • • 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 29 '22

I'm trying to fix a program, but I need help please

5 Upvotes

Hello, thanks for clicking

First off, I'm no programmer but I like to dabble and I've got a couple of successful VBA projects running in our office. I'm familiar with what classes modules subs and functions are, I know all about if statements select cases, for and do loops etc. But I'd say my knowledge safely ends there... For now. I have never used visual studio before.

I have a copy of a program that was written by an unknown author in visual basic. I need to make a small fix to this program (add a variable into a string)

Once the program is installed on my computer, I can find the project file, open it in visual studio, find the form code and the line where the string I want to edit is constructed.

The first thing I tried was to open the form1.vb file, make the changes, save, and then run the .exe but my changes weren't apparant when I run the .exe file.

So what I'm trying to do now is what I would do in VBA, insert a breakpoint and run the code to see what's going on. I have got the project file open in visual studio, form1.vb is open and I've put a breakpoint in.

Now, I'm guessing I need to 'Start' but I'm getting a few errors:

Could not find app.config Referenced component system.windows.forms.datavisualization could not be found Mswinsocklib could not be found Axmswinsocklib could not be found

And I'm getting a message box saying debugging can't be started because the .exe is missing out of the bin folder. Please build and retry or set the outputpath appropriately

Can anyone point me in the right direction?


r/visualbasic • • Jan 26 '22

VB.NET Help Nested Ifs setting and checking the length of a list

5 Upvotes

I have a variable that needs to have a message and and list names, but there is a character limit. Due to the limit, the code needs to attempt 5 options in order, until it finds one within the limit. The name is an initial with a period, a space, last name, comma, and a space. The second option is to drop the spaces after the comma. Third, drop the initial (but there is still a space after the comma and before the last name). Fourth, the spaces after the comma. Fifth, drop all names.

  1. Message (F. Last, F. Last, F. Last)

  2. Message (F. Last,F. Last,F. Last)

  3. Message (Last, Last, Last)

  4. Message (Last,Last,Last)

  5. Message

I quickly put this together by preparing two variables when the names are pulled: options 1 and 3. When the code needs to spit out the list, it uses a 4 nested ifs, first setting the variable, then checking it, steps 2 and 4 via .Replace(", ", ",").

Now that i got it out, i figure there must be a more elegant way of doing this, or is nested Ifs the way to go?


r/visualbasic • • Dec 07 '21

Ide0059 visual basic error (i need help)

5 Upvotes

it says that the variable calories is


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 • • Oct 20 '21

VB.net form & mysql database

5 Upvotes

Hi,

I wonder if anyone can help as I'm sure this probably something simple.

I've already set up the connection to the database.

How do I pull a record to populate the form? I just need to know how to access each individual field from the record so I can put it on the form.

Thanks.


r/visualbasic • • Oct 12 '21

VB.NET Help Binding ObjectGUID from Active Directory

5 Upvotes

Hi fellow VB pros!

I have a vb (.net) program which pulls a user's information from AD based on their user name. This works fine.

I now would like to add the ability to compare that information if I pull up the user's account again, so if the user's name or location has changed, I can be made aware.

I've stored the AD Object GUID (from the user account in AD) in my database.

I am modeling the below code from my previously working code (search by user name).

Is there something I can eliminate from this code since I am binding directly? It seems a little slower than when searching by user name.

[Update] - Resolved by changing

oresult = osearcher.FindAll() to

result = osearcher.FindOne()

Also removed the For Each statement as it did nothing.

     Public Sub PopADGUID(ByVal GUIDStr As String)
        If GUIDStr <> String.Empty Then

            Dim oroot As DirectoryServices.DirectoryEntry = New DirectoryServices.DirectoryEntry("LDAP://<GUID=" + GUIDStr + ">")
            Dim osearcher As DirectoryServices.DirectorySearcher = New DirectoryServices.DirectorySearcher(oroot)
            Dim oresult As DirectoryServices.SearchResultCollection
            Dim result As DirectoryServices.SearchResult

            osearcher.PropertiesToLoad.Add("name") ' full name
            osearcher.PropertiesToLoad.Add("title") ' title
            osearcher.PropertiesToLoad.Add("department") ' department
            osearcher.PropertiesToLoad.Add("telephoneNumber") ' phone
            osearcher.PropertiesToLoad.Add("mail") ' email
            osearcher.PropertiesToLoad.Add("manager") ' Manager
            osearcher.PropertiesToLoad.Add("givenName") 'First Name
            osearcher.PropertiesToLoad.Add("initials") ' Middle Initial
            osearcher.PropertiesToLoad.Add("sn") ' Last Name
            osearcher.PropertiesToLoad.Add("objectGUID") 'Object GUID in AD
            oresult = osearcher.FindAll()
            For Each result In oresult

            Next
            Me.Notes.Text = result.GetDirectoryEntry.Properties("givenName").Value


        End If

    End Sub

Thank you


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 • • Jun 20 '21

Not sure where to start

5 Upvotes

Hi everyone, I'm a business owner and I write some codes with VBA for the repetitive tasks and to organise the role of each department. I can do exactly what I need with VBA but I want to go behind the limitation of the office I want something to be fast to learn to re write my codes in this new language Do you recommend VB.net or C#?


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 • • May 12 '21

VB6 Help Anyone know how to make a windows 10 notification listener?

5 Upvotes

I want to forward notifications like new emails or discord messages to another device (the AtLegends BitPixel) and the easiest source of those are the Win10 notifications


r/visualbasic • • Apr 26 '21

Visual Basic || Final Project Year

5 Upvotes

Good afternoon everyone, I’m in my last year of schooling and I have to develop a year-end project (PAP), in my PAP, I have a problem in my listview when I add some items, automatically appears the scrollbar when I run out of field of view, but does not automatically walk down when placing a new item.


r/visualbasic • • Apr 22 '21

Windows Forms Application without console windows

5 Upvotes

I am currently creating a Windows Forms application for work.

Whenever I execute the app it not only opens the form itself but also a console window.

I've found out the apparently switching the type of the application from "console application" to "Windows Application" should result in the desired behaviour. But unfortunately it still persists.

Is there anything else that I might have to set to disable the console?

Thank you all in advance.


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 06 '21

Visual studio Datagridview - force to specific column when navigating to a new row

5 Upvotes

First two columns of a datagridview are locked; rest of the columns are for data entry, ala excel with the user tabbing to the next column. What I am trying to accomplish is, when the user tabs to, or otherwise selects a new row, the cell selected wherein data entry would occur is forced to the third column. Currently, after tabbing off the last column for any given row, the user would have to tab two extra times to get to the third column to resume data entry.


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.)