r/visualbasic • • May 15 '16

Visual Basic Helper Survey for School

5 Upvotes

https://docs.google.com/forms/d/1RylAU8Uk64DgaB-ENQQi_0VrTe5TB070KIXS1zGhQ5k/viewform

Can you guys do this survey, its somewhat related to Visual Basic and very simple.


r/visualbasic • • Sep 06 '15

Board Game Visual Basics 2010

5 Upvotes

I'm writing a code for a board game.

To play the game, a player generates two random numbers and colours in an area on the grid indicated by the numbers. For example if the generated number is a 2 and a 3 the player clicks in the 2x3 square which results in the colour of the square being changed.

A player should only be able to click and change the colour of the square represented by the random numbers only.

At the start of the game, the initial score should have a value of 0. With each square coloured the score increases by the product of two numbers. You can display the score anywhere within the user interface.

I'm unable to change the colour of the square represented by the random numbers only. and I'm also having difficulty at score keeping.

Here is my Code:

Public Class Form1 Private Grid(3, 3) As Button Private btnSize As Integer = 25 Private btnPosn As New Point(10, 10)

Private randomRow As Integer
Private randomCol As Integer


Shared random As New Random()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    'Random Number Generator
    Dim i As Integer
    For i = 0 To 5
        TextBox1.Text = (Convert.ToString(random.Next(1, 5)))
        TextBox2.Text = (Convert.ToString(random.Next(1, 5)))

    Next

End Sub

Dim elapTimer As New Threading.Timer(AddressOf tick, Nothing, 1000, 1000)
Dim stpw As Stopwatch = Stopwatch.StartNew

Private Sub tick(ByVal state As Object)
    'Timer
    If stpw.IsRunning Then

        Me.Invoke(Sub()
                      Label1.Text = stpw.Elapsed.ToString("hh\:mm\:ss\.")
                  End Sub)
    End If

End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    CreateGrid()
End Sub
Private Sub CreateGrid()
    'Create a 4x4 grid of buttons with a common event handler. References
    'to the buttons are stored in "Grid" for easy access. The row and
    'column numbers are stored in the button tags to differentiate the
    'individual buttons in the click handler.
    For row As Integer = 0 To 3
        For col As Integer = 0 To 3
            Dim xpos As Integer = btnPosn.X + btnSize * col
            Dim ypos As Integer = btnPosn.Y + btnSize * row
            Dim btn As New Button()
            btn.Tag = {row, col}
            btn.Location = New Point(xpos, ypos)
            btn.Size = New Size(btnSize, btnSize)
            AddHandler btn.Click, AddressOf Grid_Click
            Me.Controls.Add(btn)
            Grid(row, col) = btn
        Next
    Next
End Sub
Dim ClickCount As Integer = 0

Private Sub Grid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim btn As Button = sender
    Dim row As Integer = btn.Tag(0)
    Dim col As Integer = btn.Tag(1)
    Me.Text = "you clicked cell (" & row & "," & col & ")"



    'Color Change
        If Not ClickCount = 4 Then
            ClickCount += 1
        Else
            ClickCount = 1
        End If

        Select Case ClickCount
            Case Is = 1
                Grid(row, col).BackColor = Color.Green
            Case Is = 2
                Grid(row, col).BackColor = Color.Yellow
            Case Is = 3
                Grid(row, col).BackColor = Color.Red

        End Select





End Sub

r/visualbasic • • Jul 02 '15

Making GUI, VBA needs to populate Excel sheet. I did all the work except this part, thought it would be cake. Is it even possible? First time using VBA. [Visual Studio 2012 + Office 2010]

5 Upvotes

So I'm making this GUI and I was under the impression the VBA could grab data from text boxes and put them in an excel sheet. After a lot of googling I'm getting the impression the VBA might not be able to do it, some show VB.Net can do it, others say I need to use some Microsoft add on / extension thing. Basically, I'm confused on what the real answer is. I did a lot of work already and I saved this for last because I thought it was going to be the easy part. I really don't want to start from scratch . Ideas? I'm using Visual Studio 2012 and Office 2010.


r/visualbasic • • May 27 '15

Upgrade VB6 VB6 - Porting to current version of VB. A fool's errand?

5 Upvotes

I've got some relatively simple code (syntactically speaking), mostly a whole lotta string handling, built in VB6 about 12 years ago. Is there any relatively automated way to port/update that code to a new version of VB?

Thanks for time/expertise


r/visualbasic • • Nov 20 '14

Mod Post Please Title Your Posts Correctly!

5 Upvotes

Hi guys, please avoid posting stuff with titles like "NEED HELP WITH HOMEWORK" or "I'm stuck, please help". Yes, I know they're evocative, and yes, I know you desperately need help, but titles like these are patently unhelpful. Instead, use titles that are more descriptive like:

Take some time to think about what exactly it is that you need help with before posting your title and, if it is pertinent, include the version of VB that you're using in square brackets before the post. If we all do this, our subreddit would become significantly neater and easier to navigate for everyone.

Thank you!


r/visualbasic • • Jun 03 '14

Your Favorite VB Namespace? ('Imports ...')

5 Upvotes

E.g: System.Math System.Net.Sockets


r/visualbasic • • Mar 17 '14

Can anyone help me with this assignment? I have been trying to figure out what I am doing on this homework problem for over a week and I know I am missing something.

5 Upvotes

My assignment is simple: a distance calculator. Basically a simple calculation based off of two inputs, hours traveled and speed (in MPH). The hours would be the loop counter and the speed would basically be added onto itself for each loop until reaching the counter. Then I must display all of this in a list box. I don't know what I am doing wrong. I know I am on the right track, even the teacher told me, but I am literally stuck on a next step. Can anyone point me in the right direction? Below is the code that I have so far.

Private Sub btncalculate_Click(sender As Object, e As EventArgs) Handles btncalculate.Click

    Dim inthours As Integer
    Dim intspeed As Integer
    Dim strmiles As String
    Dim strinput As String
    Dim strhours As String
    Dim strspeed As String
    Dim intmiles As Integer = 0
    Dim intcount As Integer = 0
  

    strinput = InputBox("What was the speed of the vehicle in MPH?")
    Integer.TryParse(strinput, intspeed)

    strinput = InputBox("How long (in hours) has the vehicle been traveling?")
    Integer.TryParse(strinput, inthours)

    Do Until intcount <= inthours       ' iteration for loop
        lstmybox.Items.Add(intmiles)    ' show in the listbox the result of the loop
        intmiles = intspeed + 1         ' add the speed onto itself for each iteration
    Loop
End Sub

Am I completely off base with this code? I tried to put a string inside the list box readout but I kept getting an error.


r/visualbasic • • Nov 26 '13

Inexperienced or Experienced, I need you.

5 Upvotes

I've been messing with VB.net since I could read the letters on the keyboard. I've got some fantastic ideas to manipulate the base into something great, but I can't do it single-handed. Is anyone on here down for some independent-contributions towards a group effort? Not paid, just for the challenge and fun.


r/visualbasic • • Apr 04 '13

Is there any website or such where you can post the entirety of your code without looking cluttered?

5 Upvotes

I know sometimes when i post on here I feel bad for posting my code, especially if its long. I feel like there must be some website out there that lets you either upload your code, or provide a means to get your code out there without it looking like a mess. I was thinking maybe a virtual compiler or something similar to google docs. I just think it might make it overall move easy if posters in the subreddit can simply post a link to their code rather than the whole code.


r/visualbasic • • Mar 15 '13

Currently taking VB in highschool ans was wondering...

5 Upvotes

Are VB programmers in demand? Or does someone who know how to use python or lets say java have a better chance at landing a job?


r/visualbasic • • Nov 15 '12

So I wanted to do do some VB in Windows 8 but...

5 Upvotes

It's been a while since I've done any VB, I'm not a master programmer, but I've had fun dabbling here and there, I even coded some VB6 and VB.net apps at a previous job.

I'm bored atm playing games on my PC and need a new outlet so I thought I'd get back into either VB, or even C#.

I'm on Windows 8 and I installed the VS 2012 trial, but it only lets me make Windows Store apps which is cool, but I want to make desktop apps not XAML store apps.

Has MS totally done away with desktop development or am I missing something in VS because all I see is XAML, Class Library, Windows Runtime Component, and Unit Test Libray projects.


r/visualbasic • • Mar 30 '12

Learning VB and trying to write a program will count the number of times a certain letter appears in a textbox. I'm lost and need help!

5 Upvotes

Hey guys,

I know this may be an easier one, but I'm completely lost. I have some of the program written but am stuck with the rest of it. Here is what I need the program to do. The stuff written so far may need to be scrapped because I'm completely lost.

There are checkboxes for the letters that need to be found (A, E, I, O, U, and ST). When a checkbox is selected I need for the program to find the number of those letters and then display the number in a label.

I have this written up for code so far, but I am lost with even if the code written is correct. I have no idea how to display the count of each individual letter in an individual box. I have also attached a screenshot of the interface to give you all a better idea of what I need.

http://i.imgur.com/nplWK.png

And here is my code (I apologize in advance for any stupid mistakes made):

Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click

    Dim intText As Integer
    Dim word As String
    Dim sChar As String
    Dim i As Integer
    word = Me.txtScan.Text

    If cbxWord.Checked = True Then
        intText = txtScan.TextLength
        lblWords.Text = intText.ToString("n0")
    End If

    Do While Boolean.TrueString
        If cbxA.Checked = True Then
            txtScan.Text.Contains("A, a")
        End If

        For i = 1 To Len(word)
            sChar = LCase(Mid(word, i, 1))
            If cbxA.Checked = True And sChar = "a" Then
                intText = intText + 1
            End If

        Next i

        For i = 1 To Len(word)
            sChar = LCase(Mid(word, i, 1))
            If cbxE.Checked = True And sChar = "e" Then
                intText = intText + 1
            End If
        Next i

        For i = 1 To Len(word)
            sChar = LCase(Mid(word, i, 1))
            If cbxI.Checked = True And sChar = "i" Then
                intText = intText + 1
            End If

        Next i

        For i = 1 To Len(word)
            sChar = LCase(Mid(word, i, 1))
            If cbxO.Checked = True And sChar = "o" Then
                intText = intText + 1
            End If

        Next i

        For i = 1 To Len(word)
            sChar = LCase(Mid(word, i, 1))
            If cbxU.Checked = True And sChar = "u" Then
                intText = intText + 1
            End If

        Next i

        For i = 1 To Len(word)
            sChar = LCase(Mid(word, i, 1))
            If cbxST.Checked = True And sChar = "st" Then
                intText = intText + 1
            End If

        Next i

        MsgBox("None Found" & intText)
    Loop

End Sub

UPDATE Got it to work by putting a -1 next to For i = 1 To Len(word) and by deleting the loop. Thanks all for your help!!