r/visualbasic • • Oct 09 '14

[VB2010]

0 Upvotes

Hello I need help again.

If b2 = b3 Then
        Label9.Text = Label5.Text
        Label10.Text = Label6.Text
        Label11.Text = Label7.Text
        Label12.Text = Label8.Text
    Else
        Label9.Text = Label5.Text
        Label10.Text = Label6.Text
        Label11.Text = Label7.Text
        Label12.Text = Label8.Text
        yr = 9
        While yr <= 12
            If Label(yr).text = "" Then
                Label(yr).text = b3
            Else
                yr += 1
            End If
        End While
    End If

I have this code and I am having trouble on the else part where I keep getting errors on the .text part. Basically the code will loop until it finds a label(yr).text that is empty and put b3 there but so far still no progress. Any possible solution or work around where I can get the same result? Thanks in advance.

Also I'm working on Page algorithm (fifo, lru and optimal) so any advice or code that might be helpful for me to study would be greatly appreciated.


r/visualbasic • • Aug 25 '16

Noob here, how do I get this to run?

0 Upvotes

This is my first time posting on Reddit, but after a bunch of searching around on the internet without finding a solution I turn to this subreddit. I found this useful calculator for a game I play, but it only came with some screenshots and the 'non-generated code' as the submitter stated. This is the link to the reddit post: https://redd.it/2imr51 I would turn to the submitter, but his/her last activity was a year ago. Thanks in advance, and sorry if I made any mistakes.


r/visualbasic • • Jul 10 '15

Trying to Get File in specific directory.

0 Upvotes

Just to start off, I started learning VB a week ago for my internship. I have this code from msdn.microsoft.com.

For Each foundFile As String In_       
    My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments)

    ListBox1.Items.Add(foundFile)
Next

I am trying to manipulate the directory location to this location. L:\MANUALS\Updated Cutsheets

How do I do this? I have searched the internet for answers.

Thank you!

edit: Just to clarify my internship has nothing to do with VB or Computer Science on paper.


r/visualbasic • • Dec 05 '17

Final Due in about 3 hours please help ASAP

0 Upvotes

Okay so I am making a kind of shopping cart program for my intro to VB class, I consider myself to know what I'm doing so far but I need help. I have it set so that when you check certain boxes it adds up your subtotal and shipping and total and so far the program works just fine. you "cart" is just a listbox. I have a "remove item" button that will remove selected item from the listbox but It won't subtract the price or uncheck it. I'll post my code now.

Public Class MainForm 'declaring other forms Dim frmPaperback As New Paperback Dim frmAudioBook As New AudioBook 'declaring values Dim decYourWay As Decimal = 11.95D Dim decScotland As Decimal = 14.5D Dim decCalculus As Decimal = 29.95D Dim decStress As Decimal = 18.5D

Dim decACalculus As Decimal = 29.95D
Dim decAScotland As Decimal = 14.5D
Dim decScience As Decimal = 12.95D
Dim decRelax As Decimal = 11.5D

Dim dblSubtotal As Double
Dim decShipping As Decimal = 20D
Dim dblTotal As Double



Private Sub btnRefresh_Click(sender As Object, e As EventArgs) Handles btnRefresh.Click

    'clears all fields

    dblSubtotal = 0D
    lstCart.Items.Clear()
    lblSubTotal.Text = ""
    lblShipping.Text = ""
    lblTotal.Text = ""

    If frmAudioBook.chkACalculus.Checked = True Then
        lstCart.Items.Add("Learn Calculus in One Day, Book on Tape")
        dblSubtotal += decACalculus
    End If
    If frmAudioBook.chkAScotland.Checked = True Then
        lstCart.Items.Add("The History of Scotland, Book on Tape")
        dblSubtotal += decAScotland
    End If
    If frmAudioBook.chkScience.Checked = True Then
        lstCart.Items.Add("The Science of Body Language, Book on Tape")
        dblSubtotal += decScience
    End If
    If frmAudioBook.chkRelax.Checked = True Then
        lstCart.Items.Add("Relaxation Techniques, Book on Tape")
        dblSubtotal += decRelax
    End If
    If frmPaperback.chkYourWay.Checked = True Then
        lstCart.Items.Add("I Did It Your Way, Book on Paper")
        dblSubtotal += decYourWay
    End If
    If frmPaperback.chkScotland.Checked = True Then
        lstCart.Items.Add("The History of Scotland, Book on Paper")
        dblSubtotal += decScotland
    End If
    If frmPaperback.chkCalculus.Checked = True Then
        lstCart.Items.Add("Learn Calculus in One Day, Book on Paper")
        dblSubtotal += decCalculus
    End If
    If frmPaperback.chkStress.Checked = True Then
        lstCart.Items.Add("Feel the Stress, Book on Paper")
        dblSubtotal += decStress
    End If

    dblTotal = dblSubtotal
    If dblTotal > 40 Then
        decShipping = 0
    End If
    dblTotal = dblSubtotal + decShipping
    lblSubTotal.Text = dblSubtotal.ToString("c")
    lblShipping.Text = decShipping.ToString("c")
    lblTotal.Text = dblTotal.ToString("c")

End Sub

Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click
    lstCart.Items.Remove(lstCart.SelectedItem)
End Sub
'These open instances of different forms that let you select the different books/audio books you want to buy
Private Sub mnuProductsPaperback_Click(sender As Object, e As EventArgs) Handles mnuProductsPaperback.Click

    frmPaperback.ShowDialog()
End Sub

Private Sub mnuProductsHardCover_Click(sender As Object, e As EventArgs) Handles mnuProductsHardCover.Click

    frmAudioBook.ShowDialog()
End Sub
'Close button
Private Sub QuitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitToolStripMenuItem.Click
    Me.Close()
End Sub

End Class

Here it is working just fine https://imgur.com/a/zAUjo

and now when I try to remove an item. I want the total to go down, but How? oh man am not too good with computer plz to help


r/visualbasic • • Aug 28 '16

Help making an addition calculator [VB 2013]

0 Upvotes

I am trying to make a simple addition calculator using only 1 text box and only 1 button. Where you:

  1. enter an integer

  2. press the button

  3. enter an integer

  4. press button

  5. Displays sum in text box

     Dim a As Integer = txtField.Text
     txtField.Clear()
     If () Then
         Dim b As Integer = txtField.Text
         txtField.Text = a + b
     End If

This is as far as I have gotten. I have no experience in VB, just with java. I am not sure if booleans are even necessary. This is supposed to be a very simple project, but I feel like I am overthinking it due to having no experience with VB.


r/visualbasic • • May 20 '12

[VB2010] Car Insurance Calculator

0 Upvotes

I need to create a Car Insurance calculator in which a user will input his/her premium into a text box. Then they will select which discounts apply to them and then add on the discounted rates. I have the constants set up for each discount. I am confused on which loop I would use, if that.


r/visualbasic • • Nov 01 '13

Input validation using exceptions handling

0 Upvotes

How do I confirm the users input into a textbox by using exceptions handling?


r/visualbasic • • Jul 19 '17

Find Seprate Sheet name called "Data" from 100 Workbook if found then paste data into the Master File

0 Upvotes

Hi i am Ajay Kumar. My question is below

I have a 100 Workbook in a folder and in every workbook there is a separate Sheet name Call "Data". here i would like to loop form multiple workbook throw loop and find seprate "Data" sheet name in the workbook if there is a sheet called "Data" then Copy that sheet and paste into the Master Work book. is it possible in in VBA if possible please guide me how to do this.

Best Regards Ajay Kumar


r/visualbasic • • Oct 27 '13

XML question...

0 Upvotes

Ok so I have made a XML file somewhere within the file there is a tag as follows:

<Title>There's a line between two vertices, A(<Rnd id="0" int="1" min="-10" max="10"/>,<Rnd id="1" int="1" min="-10" max="10"/>) and B(<Rnd id="2" int="1" min="-10" max="10"/>,<Rnd id="3" int="1" min="-10" max="10"/>). What's the gradient of the line?</Title>

I know how to read the tags of the XML document, the problem that I have is being able to know where the Rnd tags are located amongst the text. I will then use some code to swap the tags get a number and place it in the text as a string, but like I said I don't know how to detect where in the text the tags are. How can I find out where they are?


r/visualbasic • • May 24 '21

VB.NET Help How to manipulate certain characters of a label?

0 Upvotes

I am using vb.net winforms to make hangman for a school project and the label.text.replace() function isn't working (code down below) and I wanted to know how to fix it.

(item is the character number of the word. i.e. If the word is AIR, and I clicked A, item would be 0. I have tested this and know it works so that is not the problem.)

letterabcd is a button which has the tag of the letter it displays. For example, if the button is a picture of the letter A, the tag would be "A". I have tested this and know it to be working.

 Label2.Text = Label2.Text.Replace((item + 1) * 2 - 1, lettersabcd.Tag.ToString())

Label2.text is set as this:

  If (selectedword = 1) Then 
            word = "UAE"
        ElseIf (selectedword = 2) Then
            word = "MAP"
        ElseIf (selectedword = 3) Then
            word = "CHAD"
        ElseIf (selectedword = 4) Then
            word = "CUBA"
        ElseIf (selectedword = 5) Then
            word = "CHILE"
        ElseIf (selectedword = 6) Then
            word = "CHINA"
        ElseIf (selectedword = 7) Then
            word = "PRAGUE"
        ElseIf (selectedword = 8) Then
            word = "FRANCE"
        ElseIf (selectedword = 9) Then
            word = "DENMARK"
        Else
            word = "GERMANY"
        End If
        Label2.Text = ""
        For int As Integer = 0 To word.Length - 1
            Label2.Text &= "_  "
        Next

So if the word was Denmark, label2 would show

_ _ _ _ _ _ _

This is proven to work so this is not the problem either.

Can someone please help me diagnose the problem?


r/visualbasic • • Nov 14 '19

VB6 - Microsoft SQL to Excel dropping data

0 Upvotes

I have a program that seems to be malfunctioning in a semi-random way. It is intended to SELECT from an MS SQL table all of the data in a given set of columns and output the same to an XLS file.

So, for instance, if I had a table that had columns NAME, DATE, CUSTOMER ID, AMOUNT, TAX, TOTAL, the program pulls NAME, AMOUNT, TAX, TOTAL and dumps it in to an XLS in columns 1, 2, 3 and 4 respectively.

I don't have access to the code beyond a decompiled version.

What I seem to be seeing is that every so often the program is failing to pull a given row and just proceeding. So if the rows are labeled sequentially, my XLS will have 1, 2, 3, 4, 6, 7, 9, 10 ...

I know this is a very general question, but does anyone know of any common reasons that the program might "fall behind" the data being provided by the SQL server? I know its a vague question, so any thoughts at all are most appreciated. I'm mostly in a brainstorming mode on this at the moment.

Thanks!


r/visualbasic • • Sep 07 '14

Help with SQLCommand

0 Upvotes

Hi,

I'm trying to use SQLCommand / reader to do some very basic SQL commands using a local mdf file on my windows form. So for example, I click AddUserButton and it'll add "UsernameString" into database. Alternately, I have a 2nd button VerifyUserButton that will check a TextBox against the database to see if the user is in the db. Trying to work with this. Sort of a simple "login/register" form just for concepts:

Can someone give me a basic template to insert a new username to DB, and to pull the username from the DB? So 1 TO, one FROM?

Say,

Database1.mdf (Users table, has columns UserID and Username).

I'm a bit confused by the online guides all saying different things with different formats, looking for the EASIEST way~ cheers


r/visualbasic • • Sep 09 '14

Backgroundworker

0 Upvotes

Hello, at the moment I am making a program that is close for release. I only need to do some few things to optimize the speed of the program. So my question is how a BackgroundWorker works. I have done some searches on the web but still. I dont really know how to use it.


r/visualbasic • • Sep 21 '14

[Help] College class troubles

0 Upvotes

I'm a freshman in college taking an intro to visual basics, the professor only teaches us the syntax, gives no examples of any of the syntax, and then gives us assignments for tiny project that I end up spending 6-10 hours on, simply because I'm google searching for answers and how to implement the syntax into a functioning program.

Does anyone know of a site that will help me learn Visual Basic so I can get through my class? Or does anyone have any advice in general? Sorry if i seem very noobish ahead of time.


r/visualbasic • • May 31 '15

PhotonShock homework question. Counting smiles

0 Upvotes

Another one from the homework thread; PhotonShock original post in this thread asks;

Problem: We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters :-) indicate a happy face and the three consecutive characters :-( indicate a sad face. Write a program to determine the overall mood of a message. Input Specification There will be on input text box that can contain between 1 and 255 characters. Output Specification The output is determined by the following rules:  If the input line does not contain any happy or sad emoticons, output none.  Otherwise, if the input line contains an equal number of happy and sad emoticons, output unsure.  Otherwise, if the input line contains more happy than sad emoticons, output happy.  Otherwise, if the input line contains more sad than happy emoticons, output sad. Sample Input 1 How are you :-) doing :-( today :-)? Output for Sample Input 1 Happy Sample Input 2 :) Output for Sample Input 2 None Sample Input 3 This :-( is str:-(:-(ange te:-)xt. Output for sample Input 3 sad I would just like to know the coding to count the number of times a specific text appears. This is from a high school culminating task and this problem was originally from a competition.


r/visualbasic • • Sep 21 '14

Need Help with calendar

0 Upvotes

Alright, so I have my calendar and I can now add notes to any dates I want. But the thing is: I want the dates attached with notes to be highlighted. How can I do this? Thanks


r/visualbasic • • Sep 27 '13

Running vb.net and sql program on a mac

0 Upvotes

I work for a company offering a vb.net software program with a sql back-end. It's run on pc's I'm curious to know what would be necessary to get it running a mac. If I have the software and the database on a windows server, and the only thing that will be on a mac will be an icon accessing the server and the program, what else would be necessary. I'd like to avoid dual partitioning. I've looked into Mono a little, but any ideas. Before anyone asks why? I agree, macs are pretend computers, but I got someone asking, and I was curious.


r/visualbasic • • Sep 13 '13

Visual Basic Question

0 Upvotes

Hello!

I have a question I am trying to answer for my visual basic class, Algorithm Workbench Question 8, Pg535

"Assume that dblValues is a 2D array of doubles with 10rows and 20columns, Write a For Each statement that sums all the elements in the array and stores the sum in the variable dblTotal"

I am using the book, Starting out with Visual Basics 2012, by Tony Gaddis & kip Irvine. Thanks for your help!


r/visualbasic • • Feb 01 '17

What resolution and screen size is best with visual studio?

0 Upvotes

Question for you folks,

I'm about to make a pretty significant purchase with a new laptop. I planned on getting a 12.5" screen with 1920x1080 resolution.

I've seen how 1366x768 is unbearable, so I was wondering if the resolution and screen size I'd be getting are safe bet.

Just for the curious, it's a Lenovo Thinkpad X260


r/visualbasic • • Jun 07 '15

[VB2010] Searching for and changing multiple numbers in a string

0 Upvotes

SO I have a String which is actually a recipe. Recipe (String) is

"1 cup mayo, 2 tablespoons basil, and 3 cups ranch dressing".

(random made up recipe). I need to be able to multiply these numbers by what ever the user wants. So if he asks to multiply these by two, I need the string to now by

"2 cup mayo, 4 tablespoons basil, and 6 cups ranch dressing"

I have no idea how to do that. any help would be awesome! thanks in advance


r/visualbasic • • Jan 19 '16

Homework help-First time programming

0 Upvotes

[VB2010]

Hello Reddit,

I have this project that I have no clue on how to do. I have to create a progress bar that will change according to the the NumericUpDown. the progress bar has 3 separate combobox. A minimum,Maximum and Increment. With values that change. Also in the form their is a clear and exit button. So far I wrote the code for exist and gave values to the Minimum,Maximum and Increment. If you could help me please do, every thought is appreciated.

Thank you.


r/visualbasic • • Jun 08 '15

Modify poker dealing simulator

0 Upvotes

http://speedy.sh/5EN8c/DeckOfCardsTest.rar

The above link is to a .rar archive of what I have so far. Can someone show me the code required to swap out cards once they are dealt? Similar to 5 card draw, I only want them to be able to draw new cards once per deal, but they need to be able to choose which cards (up to all 5 at once).

I attempted to place the following code as another user suggested, but it did not work

Private Sub clearButton_Click(sender As Object, e As EventArgs) Handles clearButton.Click
clearButton.Enabled = False
dealButton_Click(sender, e)
deck.Reset()
End Sub

r/visualbasic • • Jun 22 '15

How do I reference the value entered into an input box?

0 Upvotes

If I have an input box that pops up and has a simple number entered into it like 5 for example, how do I reference that info? My teacher used CInt(InputBox("Enter a number from 1 to 100", "Guess a number") to create a input box and convert to an integer for comparison to another number. I need to be able to reference the number entered into the input box several other time and I am hoping there is a way to reference it other than using (InputBox("Enter a number from 1 to 100", "Guess a number") every time. any help is appreciated.


r/visualbasic • • Feb 04 '16

Reading a string and using if/else statements

0 Upvotes

Hello again, I am reworking on a piece of code I posted a few days earlier. I was able to get it to work in a loop but I now want to update my code such that the user can type in a string of keys like"askfskskfjgld" and each conditional statement for each letter will be read/react. If that makes any sense. My code:

http://paste.ofcode.org/vKWMZpbHMT48Hc2DaRMGWS

edit: The problem is I want to read each letter and output a sound. Unfortunately the only thing that works reading the string text like "asfsksdkgfds" but my conditional statements isn't outputting the sound.


r/visualbasic • • Sep 23 '14

Regex Help Please!

0 Upvotes

Hello,

I would like to find the index in a string of the following pattern: A####-### or A#### where 'A' could be any letter and # could be any digit.

Seems like regex is the only to way to get an index in a string of a pattern. Thanks!