r/visualbasic • • Mar 02 '21

VB.NET Help Confused why this Boolean comes back as False

5 Upvotes

Hey guys, fairly new to VB. I'm trying to write a function that will check a textbox (password) to check if it has at least 8 letters, 2 numbers, and one uppercase letter. So far I have it so it will tell me if there are 8 letters. I'm somewhat confused on why this function returns false once I put any numbers in it though. Any guidance?

    Function PasswordCheck(password As String) As Boolean
        Dim passwordletter As String
        Dim passvalue As Integer = (password.Length) - 1
        Dim pass As Integer
        If passvalue < 7 Then 
            Return False
        Else
            For p As Integer = 0 To passvalue
                passwordletter = password.Substring(p, 1)
                If IsNumeric(passwordletter) Then
                    pass += 1
                    If pass < 2 Then
                        Return False
                    ElseIf pass >= 2 Then
                        Return True
                    End If
                End If
            Next
        End If

    End Function

r/visualbasic • • Feb 10 '21

Can someone tell me how to send an email triggered by cell color in Excel?

5 Upvotes

Hello, this is literally my first post on reddit. I don't know how to reddit. I hope I am redditing correctly.

I have this code that I got from online to send an email based on cell value, but I need to know how to change the code to having the trigger be based on cell color being yellow. So, if any cell in the worksheet is yellow, I want it to trigger the email. Can anyone help?


r/visualbasic • • Dec 25 '20

Can I amke someone only type numbers at console

5 Upvotes

I only need that if someone types letter or something at the console, he or she will get warning about that, I am searching for hours for that and ı still can not find it (SOLVED)


r/visualbasic • • Dec 18 '20

Help? I have been working on this for hours and cannot get it to run. The PMT is tripping me up. Please help.

Post image
5 Upvotes

r/visualbasic • • Dec 06 '20

VB.NET Help A simple application in vb.net and mysql

5 Upvotes

Can please someone help me make the structure of the database in mysql.. there are 2 forms a login form and the mainform, every user who log in have their own unique table on the form where he can add/edit delete data that other users cant see. The question is how i should make the databse in a proper way.. every user should get a new database ? Or 1 database and multiple tables ... how i should proceed ?


r/visualbasic • • Nov 26 '20

Super simple help needed please!

5 Upvotes

Hey guys, I'm sure this is SUPER basic and simple but I've been literally tearing out my hair over this!!

So I've created an SQL DB within the project, I can see it under the solution explorer, now in the form designer I want to add DataGridView so I can display info from the DB.
But when I click on choose data source, my database isn't displayed?!

I can also see the database under data connections (.mdf file)

Any idea what I'm doing wrong??

I'm trying to create a super simple little app for viewing and editing info from a simple DB but I cant even get this to work!

Thanks in advance ya'll! apologies again for n00b question


r/visualbasic • • Oct 06 '20

How to check for certain integers in a textbox.

5 Upvotes

Trying to make a program that will take 10 values from 10 textboxes and add them together.

I've tried "t1.text = Int(1)" But that only works with the number one. How do I make it so it'll check for numbers one to ten?


r/visualbasic • • Jun 27 '20

Isnt Visual Basic just CSharp but with a more english like syntax? (Makes it slightly slower to code)

5 Upvotes

r/visualbasic • • May 19 '20

Unexpected label drifting

5 Upvotes

I have a grid based map plotting program. A bunch of pictures boxes that can be loaded with stuff on click. When it was small I would just drag out the PBs and labs (a b c, 1 2 3), but it's gotten so big that I'm now programmatically adding pbs and labels

Dim locx as int = 1
Dim locy as int = 1
For I as int = 0 to 24
      Dim pb as new picture box
      With pb
           Pb.location = new point(25 * locx, 25 * locy)
           Pb.height  = 25
           Pb.width = 25
       End with
       Me.gridpan.controls.add(pb)
      If locx > 4 then
          Locx =0
          Locy +=1
     Else if locx <5 then
          Locx += 1
     End if
 Next

This works great. All the squares are flush next to eachother in a 5x5 grid. I add the same thing for the x labels

Locx = 1
Locy = 0

For I as int = 0 to 24
      Dim titlex as new label
      With titlex
           Titlex.location = new point(37.5 * locx, 25 * locy)
           Titlex.height  = 25
           Titlex.width = 25
       End with
       Me.gridpan.controls.add(titlex)
       Locx += 1
 Next

The first few labels look good, but as a whole they keep drifting further and further and further out of alignment with the picture boxes below them


r/visualbasic • • Apr 24 '20

Can't get date to show in file name

5 Upvotes

I am using some VBA from a website to print to pdf and email that email, however I can't seem to get the file name to show the date as the name. Here is the VBA that needs altering.. :

Dim CurrentMonth As String

CurrentMonth = ""

'Current month/year stored in H6 (this is a merged cell)

CurrentMonth = Mid(ActiveSheet.Range("H6").Value, InStr(1, ActiveSheet.Range("H6").Value, " ") + 1)

'Create new PDF file name including path and file extension

PDFFile = DestFolder & Application.PathSeparator & ActiveSheet.Name _

& "_" & CurrentMonth & ".pdf"

So when I input "=today()" into H6 the it will only show the dd/yyyy and it doesn't show the month.. how can I fix that?


r/visualbasic • • Mar 07 '20

VB.NET Help Search through C:\ProgramFiles - Unauthorized access help

5 Upvotes

So I've got a piece of code (below) which is supposed to scan every logical drive on a computer to track down an executable. For some reason, the program cannot access C:\Program files, which is an issue as that is where the executable is. Does anyone know of a way I can brute force the program to look into program files?

Code

            For Each Drive In System.IO.Directory.GetLogicalDrives()
                Dim ActiveDrive As New IO.DirectoryInfo(Drive)  'choose next drive letter in list
                For Each FoundDirectory In ActiveDrive.GetDirectories() 'For every folder in drive
                    Try
                        For Each File As IO.FileInfo In FoundDirectory.GetFiles(Executable, IO.SearchOption.AllDirectories)
                            NewExecutablePath = File.FullName   'Get .exe full location
                            NewInstallStatus = True             'Prepare to set installed to true in database
                        Next
                    Catch ex As UnauthorizedAccessException
                    End Try
                Next
            Next

all help is appreciated.


r/visualbasic • • Feb 21 '20

VB.NET Help DecryptString and write in plaintext to text file

5 Upvotes

Full disclosure, this is to help with me a coding challenge from HTB that has bugged me for days. Other than a bit of VB 10 years ago I'm a complete newbie.

What do i need to add/edit to the following to get it to decrypt the string and write the result in plaintext to a text file? Grateful for any help.

Public Shared Function DecryptString(pTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE=) As String

If String.IsNullOrEmpty(EncryptedString) Then

Return String.Empty

Else

Return Decrypt(EncryptedString, "13st22", "28552299", 2, "364R5DFA5DL6LE28", 256)

End If

End Function


r/visualbasic • • Feb 06 '20

VBA Excel removing undesired text from cells

5 Upvotes

I need to create a formula that cleans the text of data in a cell. My data set has different things that I need removed.

For example cell has “GANUS_LEM_Prime” The formula I create removes GANUS_ part, leaving LEM_Prime Cell can contain other type of logic like: ASIA_BIBLE_POSTCARD In that case I want the formula to keep the cell as it is, it does not have the “GANUS_” portion so formula should return the exact same data.


r/visualbasic • • Jan 22 '20

Visual studio says its using a maximum of 8 mb of RAM. Can i change that?

5 Upvotes

I'm trying to learn C#, and im using visual studio. But whenever i run a project, it shows me its usage of RAM and CPU usage. But it only shows that its using a maximum of 8 RAM, And that the project takes forever to run. Is that the actual usage of RAM of visual studio or the project runner?


r/visualbasic • • Nov 05 '19

Study Buddy?

5 Upvotes

In my first semester of programming courses and would like to find someone to study/work with.

I'm located about 30 minutes from Center City Philadelphia. Working remotely is also fine.

The textbook I'm currently using is An Introduction to Programming Using Visual Basic 10th Edition. I also rely heavily on Microsoft documentation and YouTube.


r/visualbasic • • Oct 23 '19

VB.NET Help Coin flipping program

Post image
5 Upvotes

r/visualbasic • • Oct 11 '19

Looking for DopeWars code

5 Upvotes

Hey there. I lurk a lot, but I wanted to see if the community could help me out.

Back in the day, early 2000's, I started programming in Visual Basic 6. I use to have a project I was working on that was a MUD. I got the source code from the game DopeWars because it was open source and I was able to learn and work from there. I still have most of my projects, but I am missing my Client project, So the servers runs but no one can connect XD. I will have to re-create it from scratch :( I don't think there is much of a desire for MUDs anymore, but the project is more what I am interested in. I haven't touched Visual Basic in about 12-13 years, so I want to get my feet wet again.

I was hoping that someone out there had a copy of this bad boy from back in the day that I could get a copy of. I just wanted to fiddle around and now it's driving me NUTS because I have the exe but not the project and the parameters for connection have changed. I KNOW there is a zip disk floating around with my source code on them, but I can't for the life of me find it since I moved.

Thanks to anyone reading this. If nothing else I will start completely from scratch, but I liked having a working code base to play with and learn from.


r/visualbasic • • Oct 04 '19

XML Node Names

5 Upvotes
<firstNode>
   <secondNode="data stuff"/>
        <element desc="Something"/>
        <random desc="toast"/>
        <balloon desc="float"/>
        [...] 

Given an XML such as the above, with hundreds of nodes, I want to return an array:

  • arr(0) = "element"

  • arr(1) = "random"

  • arr(2) = "balloon"

And on and on for however long my array needs to be to capture those node names. The node names can change, but will always be at the same level. I basically have the following:

strQuery = "/firstNode/secondNode"
Set genNode = doc.documentElement
Set targNode = genNode.SelectNodes(strQuery)

For Each x In targNode
	Set objNode = x.firstChild
    strResult = objNode.nodeName & ","
Next

arrRes = Split(strResult, ",")

It's returning "element" and nothing else. I can't figure out how to get all the nodenames under secondNode.


r/visualbasic • • Aug 20 '19

VB.NET Help Is there any reason to assign the return value of a function to the function name, rather than using the return keyword?

5 Upvotes

For instance:

Public Function Square(num as Integer)
    Square = num * num
    ' could say Return num * num instead - which is better?
End Function

r/visualbasic • • May 06 '19

Global Variables Help

5 Upvotes

I’m working on small project for class right now, and I’m having nothing but issues getting global variables to work. What is the easiest way to do this? I have them declared on Form1 as Public and I’m trying to use them on Form2 in order to save a value, then use that value on Form1. Using VisualStudio.

Any help is greatly appreciated!


r/visualbasic • • Mar 12 '19

Error while running my program.

5 Upvotes

have modified the connection to look for data in that directory but it's not working. can i just create a new database and remove the existing one and all it's code. any help is appreciated cause i am not a pro. copied the details below. don't know any of what that StackTrace means.

System.Data.OleDb.OleDbException

HResult=0x80004005

Message='C:\Users\myxnq\source\repos\VBAssignment\bin\Debug\DataBasedata\AssignmentDataBase1.accdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

Source=System.Data

StackTrace:

at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)

at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)

at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)

at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

at System.Data.OleDb.OleDbConnection.Open()

at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

at VBAssignment.AssignmentDataBase1DataSet1TableAdapters.Employee_Database_Table1TableAdapter.Fill(Employee_Database_Table1DataTable dataTable) in C:\Users\myxnq\source\repos\VBAssignment\AssignmentDataBase1DataSet1.Designer.vb:line 2590

at VBAssignment.DatabaseProject.DatabaseProject_Load(Object sender, EventArgs e) in C:\Users\myxnq\source\repos\VBAssignment\DatabaseProject.vb:line 4

at System.Windows.Forms.Form.OnLoad(EventArgs e)

at System.Windows.Forms.Form.OnCreateControl()

at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

at System.Windows.Forms.Control.CreateControl()

at System.Windows.Forms.Control.WmShowWindow(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.Form.WmShowWindow(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


r/visualbasic • • Feb 27 '19

Need help with my code

5 Upvotes

I am a non-user. I have basic to minimal knowledge and I need some help in writing code. Hence I will list down every fact I know about the issue and maybe one of you can help me with this.

I have been asked to work on X509 certificate code. Currently, we have a code where the encryption happens on the Hard drive of the user and we need it to happen in cache or in the backend itself. This is the code below. There was some mention of BitArrays and how we would need to use it. If the code below makes sense then please help me out!

If (AppSettings("Second Version") = "yes") Then

Cerf.Import (AppSettings("CertificatePath").ToString(), AppSettings("CertificatePassword").ToString(), X509KeyStorageFlags.DefaultKeySet)

myws.url = String.concat (AppSettings ("DomainName").ToString(), xxxxxxxx.asmx)

myws.ClientCertificates.add(Cerf)

End If

If additional details are needed, please comment below and I can get details from my superior. Because of my ignorance, I dont really know what to ask him at this point.

Thanks for reading.


r/visualbasic • • Feb 07 '19

Form1_Load not working

5 Upvotes

I have the following code in my project:

Private sub Form1_Load(sender as object, e as eventargs) handles mybase.load Msgbox("it worked") End sub

For some reason, this sub is not being called when the program is run. Please help.

(I tried the same code in a new project and it worked fine)


r/visualbasic • • Jan 09 '19

need help on VB quiz game

5 Upvotes

For my computer science coursework I'm creating a movie quote quiz in VB. I'm trying to think what would be the best way of being able to generate questions and the answers option without having to enter each question and answer as a variable within an array. any help would be appreciated.


r/visualbasic • • Dec 25 '18

VB.NET Help How to stop your program from using a file so you can move it?

5 Upvotes

Solved, see comments

I am attempting to build a image mover program that shows you images from a directory of your choosing and used keyboard input to move the file to another directory that you set. The problem I am having is that in displaying the file in a picturebox, the program is now using that file. Is there a way to tell the program to stop using that file to you can move it?

This is my code so far for that particular key press. I am aware you can simply move the file instead of copying it over and then deleting the original, but I've been playing with it to try to copy the picture, then clear the picture box in hopes that it would stop using the file, but no dice. Disclaimer: Very much work in progress code.

        If Asc(e.KeyChar) = 52 And Set4ToolStripMenuItem.Checked = True Then
            Label1.Text = "4"
            'it should move the currently selected file to folder assigned to path4
            My.Computer.FileSystem.CopyFile(defaultPath & "\" & ListBox1.SelectedItem.ToString(), path4 & "\" & ListBox1.SelectedItem.ToString())
            'I need to handle an exception if the file already exists later.

            'can I not move the file if the picture is open as the background?
            'So I can copy the file, thats good. Can I then cycle through to the next picture, and delete the prior?

            'Ok, so lets clear the background then update the list.
            Indexnumber = ListBox1.SelectedIndex
            PictureBox1.BackgroundImage = Nothing

            DeleteTemp = (defaultPath & "\" & ListBox1.SelectedItem.ToString())
            ListBox1.Items.Clear()

            'Now lets delete the last thing displayed
            My.Computer.FileSystem.DeleteFile(DeleteTemp)
            'Getting the hickup here. It seems the file is still in use somehow in the program. 


            'after this I need to repopulate the list

            'repopulate the list with all of the files found at this location
            For Each foundFile As String In My.Computer.FileSystem.GetFiles(defaultPath)
                If (foundFile.ToLower().EndsWith(".png") Or foundFile.ToLower().EndsWith(".ico") Or foundFile.ToLower().EndsWith(".jpg") Or foundFile.ToLower().EndsWith(".jpeg")) Then ListBox1.Items.Add(foundFile.Split("\")(foundFile.Split("\").Count() - 1))
            Next

            ListBox1.SelectedIndex = Indexnumber

            'After populating the list, display the image after the one just deleted (which should be the same index number) in the main picturebox
            Try
                Dim img As Image = Image.FromFile(defaultPath & "\" & ListBox1.SelectedItem.ToString())
                PictureBox1.BackgroundImage = img
            Catch ex As Exception
            End Try


        End If

I've also noticed from the resources it used when cycling through the pictures that the ram usage spikes dramatically, even when switching between 2 pictures. I think its loading the images multiple times into ram and preventing that would also be a nice thing to know if any one has any suggestions

The exception:

An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll

The process cannot access the file 'C:\Users\Worker\Desktop\picture.png' because it is being used by another process.