r/visualbasic • • Aug 04 '21

Login Page using asp.net on visual basic 2019

7 Upvotes

im trying to create a web based login page that connects to an sql database but i can't quite figure it out. does any have a full program that would open in visual studio 2019 so i can reverse engneer it.

maybe if you can add a second page that has 3 functioning buttons that would be great


r/visualbasic • • Aug 01 '21

VB.NET Help How do I see the console i.e. standard output stream?

7 Upvotes

I do Console.WriteLine("Test") and I see nothing.

In IDEs for other programming languages there is always a window that the developer can use to print things for their own information. For example in Python you would use the built-in print function. Is there a way to do this for Visual Basic in Visual Studio 2019? I thought I had read it is through Console.WriteLine() but it won't appear. Where do I find the window?

EDIT: Answering my own question. It's the immediate window tab at the bottom left.


r/visualbasic • • Jul 21 '21

A gotcha, because i relied on an inconsistent default.

7 Upvotes

Another gotcha, because i relied on an inconsistent default.

I have a program that must be run as administrator because (iirc) it attaches an ssl certificate to the connection. So, the program would check, ask, and restart as admin as required.

Well, it stopped working. Ugh! So, i created a test program, and sure enough, it failed to restart as admin:

Imports System.Security.Principal

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If Not New WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) AndAlso MsgBox("Nope", MsgBoxStyle.OkCancel) = vbOK Then
            Using Process As New Process
                Process.StartInfo = New ProcessStartInfo With {.WorkingDirectory = Environment.CurrentDirectory, .FileName = Application.ExecutablePath, .Verb = "runas"}
                Process.Start()
            End Using
        End If
        Close()
    End Sub
End Class

What went wrong? Well, after some searching and finding examples, i see that some examples set UseShellExecute to true. Reading the description of the parameter:

The default is true on .NET Framework apps and false on .NET Core apps.

Indeed, i started on framework and shifted to core in the middle. I really hate when they change defaults. In any case, 'twas but a simple fix:

Imports System.Security.Principal

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If Not New WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator) AndAlso MsgBox("Nope", MsgBoxStyle.OkCancel) = vbOK Then
            Using Process As New Process
                Process.StartInfo = New ProcessStartInfo With {.UseShellExecute = True, .WorkingDirectory = Environment.CurrentDirectory, .FileName = Application.ExecutablePath, .Verb = "runas"}
                Process.Start()
            End Using
        End If
        Close()
    End Sub
End Class

r/visualbasic • • Jul 13 '21

Weekly Post I am about to learn my first programming language i only knew pseudo code before, my teacher will teach us visual basic but people are recommending me python so what are your opinions about this and is it possible to learn both in parallel?

7 Upvotes

r/visualbasic • • May 09 '21

(VB2010) i want the picture box to turn grey until a certain condition is met. how do i do that?

Post image
7 Upvotes

r/visualbasic • • May 02 '21

(beginner vb2010) i want to add 0.1 to the value of the textbox every time the user presses the button. i'm not quite sure how to define the amount of presses though. what would i call it?

Post image
7 Upvotes

r/visualbasic • • Mar 16 '21

VB6 Help Math Functions Help

Thumbnail
gallery
7 Upvotes

r/visualbasic • • Mar 14 '21

My very "basic" program where you can control Sonic left and right. It's called SonicRun

7 Upvotes

App and source code : https://www.mediafire.com/file/qqwznzqd5kzuv4z/sonicrun.zip/file

People who are more advanced, please make it a little better if you can


r/visualbasic • • Feb 07 '21

Need help with an e-mail client

7 Upvotes

Code

      Try
            Dim server As New SmtpClient
            Dim mail As New MailMessage
            server.UseDefaultCredentials = False
            server.Credentials = New 
        Net.NetworkCredential("[email protected]", "")' my trash email adress
            server.Port = 587
            server.EnableSsl = True
            server.Host = "smtp.gmail.com"
            mail = New MailMessage()
            mail.From = New MailAddress(from.Text)
            mail.To.Add(to1.Text)
            mail.Subject = subject.Text
            mail.IsBodyHtml = False
            mail.Body = message.Text
            If CheckBox1.Checked = True Then
                mail.CC.Add(cc.Text)
            End If
            server.Send(mail)
            MsgBox("Mail sent")

        Catch ex As Exception
            MsgBox("Error while sending mail")
        End Try

When i try to send mail to another GMAIL account, its shows the error at the bottom of the code (Error while sending mail)

How do i fix it?


r/visualbasic • • Jan 26 '21

VB.NET Help Filling a DropDown from two different databases: DataAdapter or DataReader?

7 Upvotes

[I'm working on something right now, and the "problem" that needs solving seemed interesting enough to ask about. That is, i already have a solution and am working on another. I'm just curious for comment. Perhaps i'll learn something, or better yet, find out my entire approach is flawed.]

I have a dropdown filled from Access via a function. The function that gets the data:

Private Shared Function Get_List() As DataTable
    Get_List = New DataTable

    Using Adapter As New OleDb.OleDbDataAdapter(Query, Connection_String)
        Adapter.Fill(Get_List)
    End Using
End Function

Elsewhere, the dropdown datasource is assigned:

DropDown.DataSource = Get_List()

This works nicely. Fwiw, a Sub handles Handles DropDown.DrawItem to make some fancy lines and stuff.

Anyway, now i have to change it to incorporating some other data that i decided to store in Sql Server. That is, i need to get the data from Access (as already shown) and then check if the ids also exist in the Sql Server table (where it gets another id required for this program to work). How do i incorporate the two?

I started thinking (which is usually when the problems begin) the "easiest" way would be to loop through the DataTable after it's fill()ed and delete records that don't exist in Sql Server. But that's redundant, adding records just to delete them. I'd rather not add them to the DataTable in the first place. Okay, but that requires OleDbDataReader (instead of OleDbDataAdapter) and using While OleDbDataReader.Read (or its ilk) to loop through the records and check them against the Sql Server table.

I then tried figuring out how to get a DataRow (to put in the DataTable) from OleDbDataReader. Or, is that not even an option since i'm not getting the data from a DataTable, and if i really wanted a DataRow, i'd have to create one manually by looping through OleDbDataReader's result. Or maybe, i shouldn't even bother with a DataTable, and instead just use some other object to fill the DropDown (and then change other code from DataRowView to DataRow).

Then i left last night.


r/visualbasic • • Jan 13 '21

VB OpenGL Game Engine - Part 2 Rendering Game Frames

Thumbnail
youtu.be
7 Upvotes

r/visualbasic • • Nov 06 '20

Visual Studio 2019 multiple form question

7 Upvotes

I have a general question. I'm taking visual basic in school and the program I'm working on has multiple forms.

My only question is can the controls have the same name on each form?

Like, in one form have a control called "lblTotalCost" and one on the other form with the same name and not mess anything up.

Please help this noob. 😁


r/visualbasic • • Aug 25 '20

VB.NET Web API POST

7 Upvotes

I recently fired up an old project. I did some searching and it appears my old methods are quite outdated. Can anyone point me in the direction on the updated?

Basically trying to send POST requests to an API and capture the response. I was using something basic like the below. From looking the webrequest/response has been replaced?

        Dim reqstring As String = ("http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=<TrackRequest USERID='user'><TrackID ID='trkno'></TrackID></TrackRequest>")
        Dim TrackRequest As WebRequest = WebRequest.Create(reqstring)
        Dim responce As WebResponse = TrackRequest.GetResponse()
        Dim datastream As Stream = responce.GetResponseStream()
        Dim reader As New StreamReader(datastream)
        Dim responcefromserver As String = reader.ReadToEnd()
        Dim xmlout As XDocument = XDocument.Parse(responcefromserver)

r/visualbasic • • Jun 11 '20

VB Programmer Needed

7 Upvotes

Hey peeps, Sorry if this is not allowed but I am in search of a programmer. I currently have an old code that needs some small changes. Thanks.


r/visualbasic • • May 24 '20

I’m using Visual Studio 2019 to make an RPG-Style game. Does someone have any advice?

7 Upvotes

This is just a project of mine, I’m currently studying Computer Engineering and, since I started almost 10 months ago, I have only taken one programming course. So I know the basics, however I want to make the most of my time and practice my skills. Small guidance would be very much appreciated!


r/visualbasic • • May 17 '20

VB.NET Help 2 Beginner questions

7 Upvotes

I am using Visual Basic 2015.

This is my situation. I am a back office programmer. I do Oracle programming. Recently I have been given the task of maintaining a VB.Net web page. I used to code in VB in the past, so management picked me to maintain it. They will not hire anyone to maintain the web page. I have to do it.

I have been thrown into the deep end of the pool and I have to learn how to swim fast.

I have 2 question VB.Net. We are not using MVC.

1.) When making a new web page how do you make it available for others to use. I am aware that IIS is involved. Do you all have a link(s) that show how to do this.

2.) How do you make changes to existing web pages. Suppose the user wants a new command button that does something. In the past it meant a new executable. How do you put in a new features to an existing web page. Do you all have a link(s) that show how to do this.

Any help will be appreciated.

Thanking you all in advance.


r/visualbasic • • Mar 06 '19

VB.NET Help How to use vector graphics (SVG) in VB.NET?

7 Upvotes

Can anyone help me figure out the best way to add vector graphics to a VB.NET program? I have a program with a series of buttons that I would like to replace with pictures. However the size of the button / picture changes during the execution so it seems better to use a vector format than a bitmap format for the images. We have created the pictures in Inkscape and are in SVG format, but can be converted to another format.

My questions:

  1. How can I display a vector image? Picturebox and Buttons seem to support bitmap only

  2. If I were to use a bitmap on a button (i.e. Button1.Image) is there anyway to have it dynamically resize? That is, if my bitmap is larger than the button, how can I make it so the image is resized so it fits perfectly to the button?

Thanks


r/visualbasic • • Dec 30 '18

Visual/basic ../calculator

7 Upvotes

how can i make my program so that i can not write letters in the text box ???


r/visualbasic • • Oct 09 '18

[VB6] I opened the source code of my ActiveX controls project on GitHub

Thumbnail
github.com
7 Upvotes

r/visualbasic • • Jun 08 '16

Should we create a sub that is for vb Homework help?

7 Upvotes

I have been thinking about if we should have a separate place where people can place there homework stuff. What does everybody think? Will it suck out all the posts form here, forcing us to look for other stuff :)


r/visualbasic • • Apr 15 '16

Article Microsoft: C#, Visual Basic are now set to diverge

Thumbnail
infoworld.com
7 Upvotes

r/visualbasic • • May 27 '15

Article What's New in Visual Basic 14 for Visual Studio 2015 -- Visual Studio Magazine

Thumbnail
visualstudiomagazine.com
7 Upvotes

r/visualbasic • • May 09 '15

(medium)Find the longest word given a set of letters and a dictionary.

7 Upvotes

I ran across this the when I was searching for programming questions asked at interviews. This one is from Google.

Find the longest words in a given list of words that can be constructed from a given list of letters. Your solution should take as its first argument the name of a plain text file that contains one word per line. The remaining arguments define the list of legal letters. A letter may not appear in any single word more times than it appears in the list of letters (e.g., the input letters ‘a a b c k’ can make ‘back’ and ‘cab’ but not ‘abba’).

Here's an example of how it should work:

Enter your letters:  w g d a s x z c y t e i o b 
['azotised', 'bawdiest', 'dystocia', 'geotaxis', 'iceboats', 'oxidates', 'oxyacids', 'sweatbox', 'tideways']

They should be ordered from longest word to shortest returning no more than 20 words.

I personally am going to take some time with this one, I am going to try to solve a couple of ways, starting with LINQ,and moving down to old school brute force algorithms.

Just thought I would give you guys a head start :)

HINT: look up trie problems.

Here is the Debian American English Dictionary as a copy-pasta :)

Edit: After spending a couple of days on this, trying new technologies to create a solution I came to the conclusion that sometime the old ways are the best ways.

Edit 2: If this is what it takes to get into Google I am glad I don't work for them. I could not even imagine coming up with this from scratch. Need a freaking CS degree :)

Edit 3: I agree guys this is a HARD one not a medium one ;)


r/visualbasic • • Apr 16 '15

(Easy) VB Code practice: The answer to life the universe and everything

7 Upvotes

A while back we had some code practice questions posted and it kind of fell away. I am going to start up a new series of questions post them to here and post my answer. My answers will be written as a console application for we are learning to code. People can then post there answers, and we can discuss different approaches to solving it. There are no bonus points for making it as small/convoluted as you can, this is for learning. Please ask if a minified version of the code does not make sense I am sure the Authors will be happy to show you the full code.

So here is our first problem: I consider this one easy.

Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits. Example

Input File
1
2
88
42
99

Output to screen
1
2
88

Good luck, and have fun!


r/visualbasic • • Nov 28 '14

Understanding Classes

7 Upvotes

I received a PM last night from a student struggling to understand classes, constructors an de-constructors.

Lets start with an analogy;

Class = Blueprint
Object = Item created from Blueprint

Classes are a set of instructions that define what the object has for functions, properties and procedures. Instantiating and object makes a valid usable object from the class.

Lets make a basic class

Public Class House
	Public Property colour As String
	Public Property streetNumber As Integer
	Public Function CheckStreet(street As Integer) As Boolean
		If street = StreetNumber Then
			Return True
		Else
			Return False
		End If
	End Function
End Class

This class has a couple of properties describing the house, and a function that returns true or false when provided a street. Here is how you would create and instance of the class (Instantiate) that you could use.

Dim firstHouse As New House

OR
	
Dim secondHouse As House
secondHouse = New House

You man notice this class has no Sub New (The constructor) in it. This is because the VB compiler checks for the presence of a constructor in the class when it compiles. If none is found, it automatically adds a no-argument constructor.

Lets add a constructor to the above code

Public Sub New
End Sub

That's it, you can use this sub to do many things, like set values of properties, load objects with datasets, pass objects to the class that it might need.

Passing values into a constructor is done similarly to a standard sub. This is called parametrized construction

Public Sub New(_Colour as string,_Street as Integer)
	colour = _colour
	streetNumber = _Street
End Sub

To implement this class;

Dim newHouse as new House("red",35)
debug.print(newHouse.CheckStreet(35))

in your debug you will find TRUE if you were to run this class.

Deconstruction is the process of implementing IDisposable using a Dispose sub to recover used resources. The only time I ever recover my own resources is when I am dealing with massive paged datasets.

Here is the MSDN article. I don't usually bother disposing of my own resources for the .Net garbage collector deals with it. My old University professors is probably hunting me down as we speak for saying this :)

I hope this covers this a bit more clearly, if people want I can come up with more info about Inheritance.

Bone