EdwinAndrew's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
15 (0.02 per day)
Joined:
18-April 12
Profile Views:
1,242
Last Active:
User is offline Jun 05 2013 12:42 PM
Currently:
Offline

Previous Fields

Country:
CA
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
0
Icon   EdwinAndrew has not set their status

Posts I've Made

  1. In Topic: Adding a "+" between integers

    Posted 5 Jun 2013

    View Postdbasnett, on 05 June 2013 - 05:39 AM, said:

    You should really add
    Option Strict On
    as the first line of you program. Fix those errors.

    Here is an example of how it might look.

            'example
            Dim stnum As Integer
            Dim endnum As Integer
            If Integer.TryParse(TextBox1.Text, stnum) Then
                'starting number is good
                If Integer.TryParse(TextBox2.Text, endnum) AndAlso endnum > stnum Then
                    'end number is good
                    Dim s As String
                    Dim tot As Integer
                    For x As Integer = stnum To endnum
                        s &= String.Format("{0} + ", x)
                        tot += x
                    Next
                    s = s.Substring(0, s.Length - 3)
                    s &= " = " & tot.ToString("n0")
                    Label1.Text = s
                Else
                    Stop 'end number bad or less than start number
                End If
            Else
                Stop 'start number bad
            End If
    
    

    kinda new to programming but whats option strict?
  2. In Topic: Adding a "+" between integers

    Posted 5 Jun 2013

    should i use the trim function to take off the rest?
  3. In Topic: Adding a "+" between integers

    Posted 4 Jun 2013

    mind the comments because that was some random stuff i wrote down to see if that might help, can someone explain to me why i dont get the first value entered in the label ex. startingnumber=26 endingnumber=30 label only shows 27+28+29+30+++++++++++++++++++++++++++++++++++++++++++=140
  4. In Topic: Adding a "+" between integers

    Posted 4 Jun 2013

    i got most of it now
    Public Class Form1
    Dim startingnumber As Integer
        Dim endingnumber As Integer
        Dim sum As Integer
        Dim counter As Integer
        Dim Counter2 As Integer
        Dim x As Integer
        Dim y, z As Integer
        Dim stringVar As String
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            startingnumber = TextBox1.Text
            endingnumber = TextBox2.Text
            x = startingnumber
            y = 1
            z = Len(Counter2) ' x = startingnumber - 1         y = endingnumber - 1
            ' stringVar = Convert.ToString(x)
    
            For counter As Integer = startingnumber To endingnumber Step 1
                sum += counter
                Do Until x = endingnumber
                    x += 1
                    stringVar = Str(x)
                    Counter2 = Counter2 & x
                Loop
                Dim V As Integer
                For v = 0 To Len(Counter2) + z
                    If Mid(Counter2, y, 2) <> " +" Then
                        Label3.Text += Mid(Counter2, y, 2) + "+"
                    ElseIf x = "++" Then
                        Exit For
                    End If
                    y = y + 2
                Next
            Next counter
            Label3.Text = Label3.Text & "=" & sum
        End Sub
    End Class
    
    

    Now i get excess "+" signs like around 30 plus
    should i use a removestring thing and take out the last "+" signs or?

    Oh yeah on line 30 i tried something but that didnt work out so well
  5. In Topic: Adding a "+" between integers

    Posted 4 Jun 2013

    ok i kinda got it i need your help what i did is
    Dim startingnumber As Integer
        Dim endingnumber As Integer
        Dim sum As Integer
        Dim counter As Integer
        Dim Counter2 As Integer
        Dim x As Integer
        Dim y, v, z As Integer
        Dim stringVar As String
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            startingnumber = TextBox1.Text
            endingnumber = TextBox2.Text
            x = startingnumber
            y = 1
            z = Len(Counter2) ' x = startingnumber - 1         y = endingnumber - 1
            ' stringVar = Convert.ToString(x)
    
            For counter As Integer = startingnumber To endingnumber Step 1
                sum += counter
                Do Until x = endingnumber
                    x += 1
                    stringVar = Str(x)
                    Counter2 = Counter2 & x
                Loop
                For v = 0 To Len(Counter2) + z
                    If Mid(Counter2, y, 1) <> " +" Then
                        Label3.Text += Mid(Counter2, y, 1) + "+"
                    End If
                    y = y + 1
                Next
            Next counter
            Label3.Text = Label3.Text & "=" & sum
        End Sub
    End Class
    

    for example if the numbers were 1234 it now gives me 12+23+34 instead of 12+34

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Programming Languages:
Visual Basic

Contact Information

E-mail:
Private

Friends

Comments

EdwinAndrew has no profile comments yet. Why not say hello?