r/visualbasic • u/tilt_88 • May 06 '23
simon says game
hi im new and i need to make the simon says game in visual basic. what i really need is the code. if someone could help me please text me. thanks
r/visualbasic • u/tilt_88 • May 06 '23
hi im new and i need to make the simon says game in visual basic. what i really need is the code. if someone could help me please text me. thanks
r/visualbasic • u/Stildawn • May 06 '23
Hi All
New to VB.net not that this question is specific to that but I am writing it in VB.net so.
I have a number in a long variable that I'm using as a Price.
I need to simulate market forces on that number up or down in a natural way, currently I have the below:
lngPrice = lngPrice * Math.Max((random.Next(90, 110) / 100) + intPriceMod, 0.1)So currently it can move randomly between -10% (90) and +10% (110), I have a intPriceMod variable built in for later if I wanted to pass some forced up or downs into the calculations (currently intPriceMod = 0), and then a absolute minimum of -90% (0.1) to stop it from going to negatives.
This "works" but in testing over many runs it doesnt feel natural to me, and trends downwards over time.
Any maths people with better ideas haha, my only ideas so far is to have a bunch of If statements catching a bunch of scenarios, but that seems like a bad idea.
The previous prices are NOT tracked currently, and its something I'd rather avoid if possible.
Cheers
r/visualbasic • u/Firm-Analysis-790 • May 05 '23
I am new to this this. I am looking for Visual Basic 2005 or 2010 code that can send Email. I want to include it in my programming I have older code that used a Gmail account, but that has been blocked from working since May of 2022. So you many need to suggest an email server that works with your code. Ron Gerard
r/visualbasic • • May 05 '23
Hi, I need some help with a school project which involves calling an NBA Api to get statistics. This is my code below. Every time I run it I get an “Invalid Api key” response, although I have tried different websites. Is my code correct?
Dim client As New HttpClient() client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("X-RapidAPI-Host", "basketball-data.p.rapidapi.com") client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("X-RapidAPI-Key", "{{Key}}")
Dim response As HttpResponseMessage = client.GetAsync(https://basketapi1.p.rapidapi.com/api/basketball/tournament/132/season/38191/best-players/regularseason?tournamentId=1321&seasonId=38191).Result
Dim responseContent As String = response.Content.ReadAsStringAsync().Result
MsgBox(responseContent)r/visualbasic • u/jd31068 • May 04 '23
I was just searching for some info in an attempt to assist with an Avalonia question when I bumped into this article.
The Missing Avalonia Templates for VB - CodeProject
It isn't fit for production, but it is cool to see the community doing things like these.
r/visualbasic • u/chacham2 • May 03 '23
I have a DataGridView populated with data from Sql Server, whichever table is requested. There isn't that much data to show, so it is refreshed each time. It fills the data via:
With Data_Grid
.DataSource = Await function()
.AutoResizeColumns()
.AutoResizeRows()
End WithThe function itself gets the data via:
Dim Table As New DataTable()
Using Reader As SqlDataReader = Await Query.ExecuteReaderAsync()
Table.Load(Reader)
Result = Table
End UsingSo, it loads from a DataTable that i do not keep a reference to. (At least not yet. I think that is part of this question.)
That's for the Select queries. Now i want to add Insert/Update/Delete. So, i figured i could handle the RowsAdded, RowsRemoved, and whatever the data changed event is. However, those seem to handle when the DGV is drawn, and not the data itself. Further, when i check the DataGridViewRowsAddedEventArgs values, for example, the data seems empty. Perhaps because it has not been saved yet.
How do i capture the modified data to execute the appropriate query? Or am i approaching this whole thing wrong anyway? Currently, there are 12 tables.
r/visualbasic • u/No_Competition_6510 • May 01 '23
Hey, I’m doing a group project and we are creating a database with a query. We ran into an error we’ve never had before, our teacher doesn’t understand what the error is, so if anyone knows thank you, also if you need more information I will do my best however I am not the most competent with Visual Basic so if the questions were clear , and concise that would help just a heads up , here’s the error
r/visualbasic • u/chacham2 • Apr 27 '23
I have a a few panels with buttons on them, where the actions seem similar enough that i'd like to write a common routine to handler them. To that end:
For Each Panel_Control As Control In Form_Control.Controls
AddHandler Panel_Control.Click, Sub(Sender, Arguments) Handler(Panel_Control, Arguments)
NextIs there a way to use Select Case with Buttons?
The handler has to know which button was clicked, so my first thought was to use a Select Case:
Private Sub Handler(Sender As Object, Arguments As EventArgs)
Select Case Sender
Case A_Button
MsgBox("A_Button")
End Select
End SubThis generates a System.InvalidCastException: 'Operator '=' is not defined for type 'Button' and type 'Button'.' I would have used Is, but Is in a Select Case has a different meaning.
r/visualbasic • u/shiznewski • Apr 25 '23
If i have my vb.net program on C: and try to copy a file from C to the Z drive (network share) it works, but the file on the Z is unable to be renamed, deleted, moved etc. it always says it is in use.
If i move the exe to the Z drive and then try to copy the same from from C to the Z drive it works fine, and the new file can be renamed, deleted etc.
How can i fix this so that the exe can be run on the users local computer and copy files to the network?
r/visualbasic • • Apr 21 '23
years ago i used VB to create easy apps. it was 'visual basic' because you could build the app using the apps GUI and the programing would do itself. the new VB is actual coding. so where did the old VB go where you could drag and drop elements, buttons, textboxes etc and it would write the code itself, is that still a thing? is there a replacement that works the same way?
i am trying to make a simple windows app to create and track work orders.
r/visualbasic • u/Ok_Distribution_1437 • Apr 17 '23
r/visualbasic • u/Splatah_King • Apr 17 '23
I have a project that I have been working on for a few months a couple of friends were helping me on it as well through a github repo. As we were working my form design turned into a standard blank white form but I didn't think too much of it because as I was testing the changes I was making, when I clicked on the run button the form that we had designed would show up. I chalked it up to a UI bug or Visual Studio trying to save resources while working. As of this morning though after merging changes that I made yesterday, when I click that run button I get that blank white form instead of the usual form that I was working with before. As far as I know I didn't change anything on my end to swap forms or wipe the form that I was using.
I have some experience with other GUI frameworks such as Qt and I went around looking for the equivalent the Qt .ui files, which are basically programmatic description of the designer view that you get, but I could find no such file in Visual Studio. I was surprised that I couldn't find that as I assumed that .Net worked roughly the same way.
Any help would be appreciated.
For reference I am running Visual Studio Community 2022, using 4.7.2 for the framework, and I have a database in the code as well so just in case it matter I'm running SQL express.
r/visualbasic • u/BoozySlushPops • Apr 16 '23
I run a high-school theatre program. There is memorization technique involving giving actors scripts that just have the initial letters of each word of their dialogue, with punctuation preserved. (I hope we don't get too sidetracked about how/why this might work; I find that it does.)
I have a script neatly formatted in Word 2019, with all the dialogue in the paragraph style "Dialogue." I want to transform this document so that dialogue goes from this:
Did the story begin with a witch? I think it did. Yes. A horrible, evil witch.
to:
D t s b w a w? I t i d. Y. A h, e w.
I have general programming skills but none in Visual Basic. So I asked ChatGPT to write me a macro and this is what it came up with:
Sub DialogueMacro()
Dim para As Paragraph
Dim word As Range
For Each para In ActiveDocument.Paragraphs
If para.Style = "Dialogue" Then
For Each word In para.Range.Words
If Len(word) > 1 Then
If InStr(".,!?", Right(word, 1)) > 0 Then
word.Text = Left(word, 1) & Right(word, 1)
Else
word.Text = Left(word, 1) & " "
End If
End If
Next word
End If
Next para
End Sub
When I run it, the cursor blinks without moving and Word stops responding and has to be force quit.
Can you help? If I'm in the wrong sub I apologize.
r/visualbasic • u/WirtThePegLeggedBoy • Apr 13 '23
Like most others, I've left my beloved VB6 to lead a restful easy retirement, while I struggle to make VS2019 cooperate. Well, tonight was the last straw. It downloaded yet another update which completely buggered the Form Designer, and the project I was working on either became corrupted or the IDE itself just won't open the Form Designer anymore. Then the Debugger stopped working. I spent more time online looking for fixes than actually writing code.
So, I fired up my dear VB6 living way back somewhere on my hard drive, and had exactly the program I wanted to make in about 20 minutes. No fuss, no muss.
Why was everything just better back then? The IDE runs butter smooth, everything opens in the blink of an eye, the MSDN help libraries were loaded and easy to search. I miss those old days, I really really do.
EDIT: For a modern Windows app I would normally write it in C#. I've rarely had issues, so I got accustomed to it. But sometimes VS2019 can just be too much for those little tools you wanna whip up in 20 minutes to help your workflow. That's where VB6 came through, in this case. 20 minutes of VB6 and job done, VS 2+ hours of scouring the web for solutions for why VB2019 is breaking and meanwhile no progress is made on the project.
r/visualbasic • u/loomingfinger99 • Apr 12 '23
Hello all!
I need to learn VB.NET for my job and I've been trying to search for resources to learn for the longest time with no success. Can anyone here point me to any good resources to learn the language? Thanks!
r/visualbasic • u/bogdanelcs • Apr 10 '23
r/visualbasic • u/Gjcerda • Apr 05 '23
I was handled a project with 280 different forms where we need to change the colors and font properties of all forms. I decided to make a subprocess that can do this called Color_form and it works good, but now I would also like to see the change reflected in the design interface instead of just once the project is up.
Right now I'm having Color_form to be executed as the first line inside the Form_Load subprocess, but I would like to be able to execute them in a way that changes the design interface permanently. This way when someone else takes the project what they see there it matches with what I have in code.
Anyone has any idea on how to do this?
r/visualbasic • u/InternationalDust720 • Apr 04 '23
The company I work for provides a pdf generation service for some customers. These pdfs are generated in RGB, however some of them want to print their pdfs, like magazines. For that, we need to convert these pdfs to CMYK and we use Adobe Acrobat Pro XI for that. But I don't want to do it manually every time anymore. We would like to automate this conversion, but we use the Visual Basic 6 programming language in our products. What would be the best alternative (free if possible)? Remembering that we do not want to use third-party sites for this, we would like to provide the solution to our customers.
r/visualbasic • u/Hasherucf • Apr 03 '23
Hi Guys. Trying to follow a redirecting url but my source doesnt seem to be working. tried httpclient
and webclient. If you open the url in a browser you can see it change several times. But this code exits quick. Any help appreciated.
Sub Main()
Dim response = FollowRedirectsAsync("https://secure.id.afl/")
End Sub
Public Async Function FollowRedirectsAsync(url As String) As Task(Of String)
Dim client As New HttpClient()
client.MaxResponseContentBufferSize = 1000000 ' Set a max buffer size to prevent OutOfMemoryExceptions.
Dim response As HttpResponseMessage = Await client.GetAsync(url)
' Follow redirects.
While response.StatusCode = Net.HttpStatusCode.Found OrElse response.StatusCode = Net.HttpStatusCode.Moved OrElse response.StatusCode = Net.HttpStatusCode.SeeOther OrElse response.StatusCode = Net.HttpStatusCode.TemporaryRedirect
url = response.Headers.Location.ToString()
response = Await client.GetAsync(url)
End While
' Read and return the final response content.
Dim content As String = Await response.Content.ReadAsStringAsync()
Return content
End Functionr/visualbasic • u/HereForAlternatives • Apr 04 '23
Howdy,
Been probably 15 years since I've touched VB.
We have a PLC in the shop that's apparently "never worked" so of course the guy who can type > 60 WPM is tasked with fixing it.
This is VB6.0.
Basically, from what I can gather, the set up is as follows:
BK Precision Frequency Counter >---< VB Application over COM >---< Allen Bradley Controller.
Basic code snippet I'm struggling with is here on the line marked with the "???".
The part I'm struggling with is how VB is interpreting/compiling this line. The [VB Documentation](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa242763(v=vs.60)) says that the & is used for string concatenation, but then it's somehow resolved the "HD" to binary values?
There's a fundamental break here in my understanding, and I don't wanna start making unfounded assumptions.
Note: I've also seen "Chr( $'blahblah` ). Is this related?
r/visualbasic • u/National-Bullfrog-16 • Mar 30 '23
Im new to coding world, im studying and trying to learn vb 6
r/visualbasic • u/jd31068 • Mar 29 '23
Nostalgic for VB? BASIC is anything but dead
Cool little article touching on other Basic interpreters around and some that came and went.
r/visualbasic • u/ritiange • Mar 27 '23
On the form, there are two buttons with no functionalities. The code is as follows:
Public Class Form1 Dim myGraph As Graphics Dim isDrawing As Boolean
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myGraph = Me.CreateGraphics()
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
isDrawing = True
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
isDrawing = False
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If isDrawing Then
Dim b As SolidBrush = New SolidBrush(Color.Red)
myGraph.FillEllipse(b, e.X, e.Y, 5, 5)
End If
End SubWhat's interesting is that, although I can draw on the window, when I hit tab key or alt key, what I have drawn is erased. What's more interesting is that, this erasing behavior only happens the first time I hit the keys --- if i hit the same keys again, they no longer erase the graphics.
r/visualbasic • u/hank-particles-pym • Mar 26 '23
I havent used VB in a while heres where I am:
Imports System.Net.WebRequestMethods.Http
Imports System.Xml
Imports System.Net.NetworkInformation
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim macAddresses As New List(Of String)()
Dim vendorInfo As New Dictionary(Of String, String)()
' Get list of devices on network and their MAC addresses
Dim interfaces As Net.NetworkInformation.NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
For Each netInterface As Net.NetworkInformation.NetworkInterface In interfaces
Dim address As PhysicalAddress = netInterface.GetPhysicalAddress()
If address.ToString() <> "" Then
macAddresses.Add(address.ToString())
End If
Next
' Loop through MAC addresses and get vendor information
Dim client As New HttpClient()
For Each mac As String In macAddresses
Dim url As String = "http://www.macvendorlookup.com/api/v2/" & mac
Dim response As Net.HttpResponseHeader = client.GetAsync(url).Result
Dim responseString As String = response.Content.ReadAsStringAsync().Result
' Parse XML response and extract vendor information
Dim xmlDoc As New XmlDocument()
xmlDoc.LoadXml(responseString)
Dim vendor As String = xmlDoc.SelectSingleNode("//vendor").InnerText
' Add vendor information to dictionary
vendorInfo.Add(mac, vendor)
' Display vendor information in a message box
MessageBox.Show(mac & " - " & vendor)
Next
End Sub
End Class
The error I am getting is:
Error 1 'Content' is not a member of 'System.Net.HttpResponseHeader'. C:\Users\X\Desktop\NetScanTool\NetScanv1\NetScanv1\Form1.vb 27 44 NetScanv1
Any help would be appreciated.
r/visualbasic • u/transdimensionalmeme • Mar 26 '23
Hi,
So I am working on streaming video back and forth accross my network.
Right now I can stream any whole screen to any other computer and it works great, although latency is still in the 200ms range.
my streaming command is
ffmpeg -f gdigrab -framerate 60 -video_size 3840x2160 -i desktop -vf "scale=1920:1080" -c:v h264_nvenc -preset llhp -tune ull -f mpegts udp://239.0.0.10:9998and my receiver is
ffplay -hide_banner -fflags nobuffer -flags low_delay -probesize 20000 -analyzeduration 1 -strict experimental -framedrop udp://239.0.0.10:9998Now I would like to write a minimalist VB.net application to replace this receiver command
So what we have here is a h.264 video stream, in an MPEG transport stream container sent as UDP packets over multicast
I would like to create a borderless window that just listens to this address and importantly, this window should have a mousemove and mouseclick function, that's really the hard part.
Is there a way to do this, decode the video using local hardware video decoder, hopefully without relying on third party software/libraries to do this. Just whatever ships with vb.net and preferably stuff that ships with v4.0.30319 which is .net that come with win10 22h2
So to break down this problem
For #1 that seems feasible entirely using vb.net native libraries, this example code seems straight forward
https://www.codeproject.com/Articles/8877/UDP-Send-and-Receive-using-threads-in-VB-NETAs for #2, I don't know if there is any way to do this using only native .net functions and libraries
I did find two projects that seem be not incompatible with vb.net and they are
https://github.com/Cinegy/TsDecoder/releases/tag/v2.1.0
https://sourceforge.net/projects/directshownet/files/DirectShowNET/v2.1/As for #3
This is the real voodoo black magick, again I'm really not seeing any native vb.net that could do this part but there is a library
https://github.com/cisco/openh264/and a vb.net library wrapper
https://github.com/secile/OpenH264Lib.NETUnfortunately, reading the code this appears to be turning every frame into a bitmap, which I suspect is going to gobble up all of the CPU
So here is my broader question, do you know of a more straightforward or more efficient way to do this, something not as reliant on external libraries perhaps ? Although at least all of these libraries are GPL and my end product would be open source as well so it's all good on the licensing front.
P.S. the end goal is, screen capture only a window from a WM, stream this window over the network to another computer. Display the streamed window, capture mouse and keyboard events, send those back to the sender over the network, and have some other bit of code execute those event on that window in the VM.
Essentially, streaming application over network and the ability to drag application from one computer to another transparently over the network.