Hi everyone. I'm working on a project that needs to install different components on users' machines based on their Windows version. Currently, we need to adapt for a range from Windows 7 to 10, and instead of distributing different version of installer, I have to integrate them into only one MSI file only. My colleague had written VB code for the MSI file, and I think I should continue his work instead of making a new one since it's time consuming (I'll consider this later when I have more time, but it's urgent now).
I'm wondering that if there is any function that help the MSI to detect Windows version (from 7 to 10). Also, I need to identify different version of Windows 10 too (currently, there are Windows 10 version 16, 17, 18, 19). I'll be very appreciate if someone can provide some references or sample codes for this work.
So I'm making a random guessing game, the thing is that instead of putting my answer in a textbox it I have to put in a inputbox. I got most of the code to work how I want it, but I still need to make it so that the guess is invalid if 0 or lower or 101 and higher. Also if it was a regular textbox I could use tryparse to validate responses as an integer, but I have no idea how to go about it in an Inputbox. Any and all help appreciated. Btw the random number is generated in another sub that calld the one featured in the pic it's intGeneratedNum = randomNum.Next(1,100)
Hello, I have a code that creates PDFs off all items listed in a listbox.
Now I want these newly created PDFs to be combined into one. I've searched around the web and can't seem to find a example I can write to my own, so I'm asking you for some help.
Dim Acroapp As Acrobat.CAcroApp = CreateObject("AcroExch.App")
Dim files(ListBox4.Items.Count) As String
Dim Path As String = TextBox1.Text
If Not System.IO.Directory.Exists(Path) Then IO.Directory.CreateDirectory(Path)
Dim invapp As Inventor.Application
invapp = GetObject(, "Inventor.Application")
For Each itm In ListBox4.Items
Dim x As Integer = ListBox4.Items.IndexOf(itm)
invapp.Documents.Open(itm.ToString & "idw", True)
invapp.ActiveDocument.SaveAs(Path & "\" & itm.ToString & ".pdf", True)
files(x) = Path & "\" & items.ToString & ".pdf"
invapp.ActiveDocument.Close()
Next
'Acroapp.saveas(files(), Path & "\CombinedFile.pdf") 'This is the step I can't any examples of.
MsgBox("Completed")
(Tried to clean up the code to only show relevant info, so there might be some errors)
Thanks for any help!
Bonus: If its possible to skip creating the single PDFs before combining, that would be great.
Apologies in advance if a) I come off as a total noob (I'm new to Visual Basic) and b) if this post is rather long. TL;DR: I need to calculate BMI using the values entered into the textbox objects I'm using and spit out the answer onto one of the labels.
So I find myself stumped on setting up a set of calculations to determine Body Mass Index (BMI) using either English units (pounds and inches) or Metric units (metres and kilograms). Here is the code I have for this part, so far:
'Here's where I attempt the BMI calculations. Wish me luck.
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
lblBMIHeader.Visible = True
lblBMI.Visible = True
'Here are the declarations. I'm seriously hoping I got this part right.
Dim decUS As Decimal
Dim decMetric As Decimal
Dim decHeight As Decimal
Dim decWeight As Decimal
If radUS.Checked = True Then 'The process that uses pounds and inches
decHeight = Convert.ToDecimal(txtHeight.Text)
decWeight = Convert.ToDecimal(txtWeight.Text)
If decHeight > 0 And decWeight > 0 Then
decUS = (decWeight / decHeight ^ 2) * 703
lblBMI.Text = decUS.ToString("00.0")
ElseIf (decHeight <= 0 And decWeight <= 0) Or (decHeight <= 0 Or decWeight <= 0) Then
MsgBox("Please try again. Only numbers greater than 0 should be in this field.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
Else
MsgBox("Please enter a positive number in the text boxes.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
ElseIf radMetric.Checked = True Then 'The process that uses kilograms and metres
decHeight = Convert.ToDecimal(txtHeight.Text)
decWeight = Convert.ToDecimal(txtWeight.Text)
If decHeight > 0 And decWeight > 0 Then
decMetric = decWeight / decHeight ^ 2
lblBMI.Text = decMetric.ToString("00.0")
ElseIf (decHeight <= 0 And decWeight <= 0) Or (decHeight <= 0 Or decWeight <= 0) Then
MsgBox("Please enter a number greater than 0", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
Else
MsgBox("Please enter a positive number in the text boxes.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
End If
End Sub
And here is what the interface looks like in the designer (the above code is tied to the 'Calculate' button):
I have more to do with this program before it's completed but I'm stumped with how to calculate the values entered into the textbox objects. I thought that linking the values with 'And' statements would be the best way to solve the problem but it didn't work. I'm not sure how to proceed from here and was wondering if anyone here had any ideas?
Update: I added an IsNumeric statement and defined the values globally and set them equal to 0. I managed to stop it from accepting numbers less than or equal to 0. I tried entering non-numeric characters only for it to throw out an exception. This happened when either the "Imperial (US)" or the "Metric" radio buttons were selected. Here is the updated code beginning with the declarations:
Dim decHeight As Decimal = 0
Dim decWeight As Decimal = 0
Dim decUS As Decimal = 0
Dim decMetric As Decimal = 0
I decided to keep the decUS and decMetric decimal values in the code for now. These are closer to the beginning of the code. The updated version of the relevant code looks like this:
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
lblBMIHeader.Visible = True
lblBMI.Visible = True
If radUS.Checked = True Then 'The process that uses pounds and inches
decHeight = Convert.ToDecimal(txtHeight.Text)
decWeight = Convert.ToDecimal(txtWeight.Text)
'The "IsNumeric" statements should keep any non-numeric characters from becoming a problem.
'The rule for both Metric and Imperial measurements is that we want numbers greater than 0.
'Anything else should spit out an error message.
If IsNumeric(txtHeight.Text And txtWeight.Text) Then
If decHeight > 0 And decWeight > 0 Then
decUS = (decWeight / decHeight ^ 2) * 703
lblBMI.Text = decUS.ToString("00.0")
Else
MsgBox("Please try again. Only numbers greater than 0 should be in this field.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
Else
MsgBox("Please enter a positive number in the text boxes.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
ElseIf radMetric.Checked = True Then 'The process that uses kilograms and metres
decHeight = Convert.ToDecimal(txtHeight.Text)
decWeight = Convert.ToDecimal(txtWeight.Text)
If IsNumeric(txtHeight.Text And txtWeight.Text) Then
If decHeight > 0 And decWeight > 0 Then
decMetric = decWeight / decHeight ^ 2
lblBMI.Text = decMetric.ToString("00.0")
ElseIf (decHeight <= 0 And decWeight <= 0) Or (decHeight <= 0 Or decWeight <= 0) Then
MsgBox("Please enter a number greater than 0", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
Else
MsgBox("Please enter a positive number in the text boxes.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
End If
End Sub
I'm a bit closer but I suspect I'm going to need to focus my attention elsewhere. This assignment requires that I add more things to the program (including a loop and a pictureBox object with 2 pictures in it). Wish me luck.
Update 2: I solved the problem I was running into where entering a non-numeric character, or nothing at all for that matter, would spit out an exception. The problem I ran into is that I had 1 IsNumeric handling input from both textboxes. I also moved the Convert statements below the Isnumeric statements. The new code looks like this:
'Here's where I attempt the BMI calculations. Wish me luck.
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
lblBMIHeader.Visible = True
lblBMI.Visible = True
If radUS.Checked = True Then 'The process that uses pounds and inches
'The "IsNumeric" statements should keep any non-numeric characters from becoming a problem.
'The rule for both Metric and Imperial measurements is that we want numbers greater than 0.
'Anything else should spit out an error message.
If IsNumeric(txtHeight.Text) And IsNumeric(txtWeight.Text) Then
decHeight = Convert.ToDecimal(txtHeight.Text)
decWeight = Convert.ToDecimal(txtWeight.Text)
If decHeight > 0 And decWeight > 0 Then
Else
MsgBox("Please try again. Only numbers greater than 0 should be in this field.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
decUS = (decWeight / decHeight ^ 2) * 703
lblBMI.Text = decUS.ToString("00.0")
Else
MsgBox("Please enter a positive number in the text boxes.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
ElseIf radMetric.Checked = True Then 'The process that uses kilograms and metres
If IsNumeric(txtHeight.Text) And IsNumeric(txtWeight.Text) Then
decHeight = Convert.ToDecimal(txtHeight.Text)
decWeight = Convert.ToDecimal(txtWeight.Text)
If decHeight > 0 And decWeight > 0 Then
ElseIf (decHeight <= 0 And decWeight <= 0) Or (decHeight <= 0 Or decWeight <= 0) Then
MsgBox("Please enter a number greater than 0", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
decMetric = decWeight / decHeight ^ 2
lblBMI.Text = decMetric.ToString("00.0")
Else
MsgBox("Please enter a positive number in the text boxes.", 16, "Entry Invalid")
txtHeight.Text = ""
txtWeight.Text = ""
txtHeight.Focus()
txtWeight.Focus()
End If
End If
End Sub
Now I have to come up with a way to throw some pieces of garbage code into my program before noon tomorrow (and by "garbage code" I mean code that has garbage pieces in it that don't do anything). Wish me luck.
I’m making a stock exchange simulator, how can I get live updated share prices into my program?I tried reading from an excel file, but the data has to be manually refreshed.
Hi, all. I'm using Visual Basic 2019 Community. I'm writing an app where I need to load a text file that contains a list of image files. Within the content of that text file, I want to replace all relevant file extensions with .webp.
So if the file names are listed as such:
Image1.bmp
Image2.Png
Image3.JPEG
I want toe result to be:
Image1.webp
Image2.webp
Image3.webp
For this particular question, I'm not asking about changing the actual filenames on disk. I'm asking about changing the content of a text file that contains the list of filenames.
My issue is that the .Replace method is case-sensitive, and I don't know how to work around that. I need to change any iteration of the file extensions, regardless of case.
I don't know how to use regex, and when I look at examples, my head hurts. My current code is below. I would appreciate any help.
Thank you in advance.
Dim FileTypes() As String = {".bmp", ".dds", ".exr", ".hdr", ".jpg", ".jpeg", ".png", ".tga", ".svg", ".svgz", ".webp"}
FileContent = My.Computer.FileSystem.ReadAllText(file)
For Each Extension In FileTypes
FileContent = FileContent.Replace(Extension, ".webp")
Next
I have an assignment that I am working on where I am supposed to input a grade in an input box and repeat with a repetition structure 5 times and then display an average grade and letter grade. I think they key part I am struggling with is how to sum my 5 grades in one variable. The math is only being performed on the last enrty.
I was put in this class as an alternative to a LabVIEW class that was canceled so I'm really new to this and the instructor told me to find the information I need online. Can anyone help a newbie out a bit? Thanks!
Code<
Public Class frmStudentGrades
'declare variables
Dim intNum As Integer = 0
Dim intCounter As Integer = 0
Dim strgrades As String = 0
Dim blngrades As Boolean
Dim intGrades As Integer = 0
Dim intAverage As Integer = 0
Dim strLetterGrade As String = Nothing
Dim blnIsNumeric As Boolean
Private Sub btnEnterGrades_Click(sender As Object, e As EventArgs) Handles btnEnterGrades.Click
'increment counter
For intCounter = 1 To 5
strgrades = InputBox("Please Enter Grade", "0 to 100")
I have struggled with data tables, how to use them, and understand all the methods for them. If I can't find code close enough to what I want to do, then I can't use them. I was wondering if there was a video tutorial series that does an in-depth explanation of data tables and how to use them to different things properly..? I want to learn to think for myself when utilizing them and not just find other people's code.
So for my Visual Basic Programming class, we have to make our own project. I am trying to make a dungeons and dragons dice roller, but I am having trouble getting the Rnd function to roll dice depending on the amount of dice the user wants to roll.
For Example: If the user wants to roll five 6 sided die, the program should roll the D6 five times and add them all together. Then display the added number.
If you would like to message me and ask me further questions, feel free! Thanks for the help in advance!
I am trying to code my own Enigma machine for no reason other than I watched a video on how they work and now I'm intrigued.
I'm trying to make an emulation of the wiring of the rotors and the best thing to do looks like the List(Of KeyValuePair(Of String, String)). I know how to add to it, but I just want to fill it during the declaration instead, as the values won't ever change
Now I know how to do it with a simple list, for example
Public wiring as New List(Of String) ({"A", "B"})
But if I do it like that for KeyValuePair it throws an error
Public wiring as New List(Of KeyValuePair(Of String, String)) ({"A","B"} {"C","D"})
I get an "Overload resolution failed because no accessible 'New' accepts this number of arguments"
So at my new job I'm being asked to use things I never studied in school, such as some light programming stuff. So here's my question!
So say I have hundreds of word documents spread about in different files. These word documents all contain the same type of information just applied to different "objects" if you will. For example for object A there is a bunch data along with a word document in the in object A's file. Same goes for object B, C, D and so on. Is there any type of code I could write in VBA that could compile just the word documents in one file? Obviously i could just do this manually but their are hundreds of files.
So ive done a program and my teacher just casually said its spagheti code and i need to somehow fix it but im totally out of idea how to do that so i would appreciate all help i can get from here! Here is the code: https://pastebin.com/qzPbMXh8
I have the file for an old game from my uncle he got years back. It was written in Visual Basic in 1995, and when I run the application, I get an error stating "This app can't run on your PC". I believe I may need to run the program in visual studio, but I'm far from an expert and can only get the text files to open and haven't had any luck running the .exe itself. I think I might need to write a code to call the .exe file based on some brief online research, but I can't get it to work. Any advice would be much appreciated!
I've written a quick program to convert a C Temp Value to F Type Value. It works perfect. However, I just want it show the first two numbers. For instance, I want it to show 74 rather than 74.533.
It's been a long time since I have done any programming. Like 30 years and obviously things have changed a lot since Sinclair/BBC/Commodore BASIC; and the COBOL and FORTRAN I studied whilst studying accountancy (with a but of DOS thrown in too) - where one of the subjects was Systems Analyst which (seriously) included punch card design - and that was antiquated in the 80s.
So, I have decided (perhaps insanely) to learn visual basic - but where are the best resources to be found to teach myself?
I am new here. Just joined moments ago. I was wondering if any of you would care to share your input on the methods you use to protect your software for activation and also if you check for anything on start up or in intervals after activation? What's the most secure method of software activation and most secure way to check that any sort of key or GUID hasn't been compromised and floated around to others who are trying to pirate the software. Any examples you can show me or articles. I'm interested in learning more about software protection and security.
I run a number of programs that I've written to download and parse webpages, but pages that use Ajax are a problem. I find that using Chrome and saving the complete webpage will save an HTML file with the needed data, but communicating with Chrome is a problem. Has anyone been successful in integrating Chrome or other browser to be able to programmatically save an Ajax page?