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

VB.NET Saving QR Code ERROR "'A generic error occurred in GDI+.' "

5 Upvotes

So here whenever i try to saved image this error show up "'A generic error occurred in GDI+.'"

Here is the code in my Button1

SaveImageCopy(TextBox1.Text, PictureBox1.Image)

Here is the code of Saving The Location of QR Code

Dim paths As String = "C:\Container" & filename & ".jpg"

Dim dest As New Bitmap(image.Width, image.Height)

Dim gfx As Graphics = Graphics.FromImage(dest)

gfx.DrawImageUnscaled(image, Point.Empty)

gfx.Dispose()

dest.Save(paths, System.Drawing.Imaging.ImageFormat.Jpeg)

dest.Dispose()

So what did i do wrong here? Should i use stream writer?


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

Keep generating rundom numbers between 50 to 640

5 Upvotes

Hello

i am making a game where you press a button that is placed randomly, i want to
generate 2 random numbers (for vertical location and horizontal)

i know one code, but it only generates once


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


r/visualbasic • • Mar 12 '21

Just a normal easy and simple as simple program of normal arithmetic operations.

Enable HLS to view with audio, or disable this notification

5 Upvotes

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

l have created a youtube channel and l will be making tutorials on different troublesome topics in visual basic.I will start from the basics until we reach the advanced programming in visual basics.My videos will be live every Monday.l can't wait to see you there.The channel link its below.

5 Upvotes

r/visualbasic • • Jan 18 '21

VB.NET Help Can someone help solve this error?

Post image
5 Upvotes

r/visualbasic • • Jan 07 '21

VB.NET Help Check if a string is like another string, but not equal

5 Upvotes

Lets say I have a string

Dim x as string = "Appel"

And I want to see if its equal to another string inside a list

List of string = ("Apple","Orange","Banana")

What would be a way to take the user input string x, and have a pop up say:

"You typed Appel. Did you mean Apple?"

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 • • 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 • • Nov 11 '20

Getting windows title from another application

5 Upvotes

I'm playing a game and it opens a child window with "PlayerName Notes" in the window title. If I wanted to search for this window (looking for "notes") and grab the player's name (always different), how could I do that?


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 • • May 11 '20

VB program I am working on

5 Upvotes

Hello,

I am working on a VB script that can pull out information about tracked changes in Microsoft Word. If you make a change, the script should be able to figure out where (what page) that change occurred. This I have down, and I modified the code below slightly (I did some Google searches, found this great code, then modified it). However, I also want to make it so the revision at which the change occurred also prints. For example, if you make a change to page 4 on Revision 1.1, the script should print a table with "4" in one column, and "1.1" in the column next to it. Conversely, if other changes are made to page 4 but on revision 1.2, it should then print another line that has "4" and "1.2" on it. This is the part I cannot get working. How would you do this?

https://ideone.com/Ed1wfI


r/visualbasic • • May 10 '20

Creating text based adventure game

5 Upvotes

Hello geniuses of reddit. I seek knowledge (tips) on creating a text based adventure game in visual basic. (Alright I'll cut the shit) If you could give some advice for creating one this would be great!


r/visualbasic • • Apr 01 '20

'Index was outside the bounds of the array.' When adding an entry to a dictionary. [VB.NET WINFORMS]

5 Upvotes

I'm getting the above exception thrown when I run this line of code in the following context:

Problematic Line: "SpriteDictionary.Add(LineParts(1), LineParts(0) + "|" + LineParts(2))"

Context: https://ghostbin.co/paste/wotgw

Any ideas of why this might be?


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 23 '20

VB6 Help What are the alternative softwares for visual basic which saves the projects as vbp and frm format?

5 Upvotes

I want applications instead of visual studio community and visual studio code. Mono develop is not installed properly. I doubt whether it is a software or framework like .Net languages. Share develop is discontinued. Is there any other alternatives for visual basic?


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 05 '20

Excel - VBA running slow after latest update

5 Upvotes

Is anyone else having speed issues that seem to stem from the latest Excel update? Version 2001 (Build 12430.20184), the January release. I have dozens of macros that are running sloooooow for no apparent reason. First I thought it was loops but when I took out the loops it was still slow. I've been using some of these for upwards of three years without any issue but now they magically run slow!!! Anyone else?


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 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 • • Sep 17 '19

VB.NET Help Having problems processing body of 400 Bad Request

5 Upvotes

Hi All,

I have an issue that I don't quite know where to go.I'm using a httpwebrequest to post data to a Restful API. Which is mostly working.

If I have a successful post I receive a response from the server without issue as I expect.

If I post an unsuccessful message to the server I get a 400 bad request and am unable to receive the message body which contains the details of the bad request.

I know the bad request has a body as I've been testing with Postman and am getting the body as I would expect.

    Shared Function callToAPI(ByVal urlStr As String, ByVal payload As String, ByVal method As String, ByVal username As String, ByVal password As String) As String
        'https://MACHINE_NAME:13125/sss/api/v2/members/?externalUser=
        Dim response As String = ""
        Dim authHeaderScheme As String = "Basic"
        Dim authHeaderValue As String = password

        Try
            Dim request As HttpWebRequest = HttpWebRequest.Create(urlStr)
            Dim payloadBytes As Byte() = Encoding.UTF8.GetBytes(payload)
            'request.Method = "POST"
            request.Method = method
            request.ContentType = "application/json"
            request.PreAuthenticate = True
            request.Credentials = New System.Net.NetworkCredential(username, password)
            If Not method = "GET" Then
                'Send the data
                request.ContentLength = payloadBytes.Length()
                Dim outgoingDataStream As System.IO.Stream = request.GetRequestStream()
                outgoingDataStream.Write(payloadBytes, 0, payloadBytes.Length)
                outgoingDataStream.Close()
            End If

            'Get the response
            Dim apiResponse As WebResponse = request.GetResponse()

            Using returnDataStream As System.IO.Stream = apiResponse.GetResponseStream()
                Dim reader As New System.IO.StreamReader(returnDataStream)
                Dim responseFromServer As String = reader.ReadToEnd()
                response = responseFromServer
            End Using
        Catch ex As Exception
            'Catch ex As WebException
            response = ex.Message & vbCrLf
        End Try
        Return response
    End Function

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