Click here to Skip to main content
15,899,825 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVS 2012 - Install Shield Pin
No-e15-Oct-12 6:10
No-e15-Oct-12 6:10 
AnswerRe: VS 2012 - Install Shield Pin
Dave Kreskowiak15-Oct-12 7:44
mveDave Kreskowiak15-Oct-12 7:44 
Questionhaving problems with program to merge sort a given set of input Pin
benkazy101415-Oct-12 0:23
benkazy101415-Oct-12 0:23 
QuestionRe: having problems with program to merge sort a given set of input Pin
Eddy Vluggen15-Oct-12 0:50
professionalEddy Vluggen15-Oct-12 0:50 
AnswerRe: having problems with program to merge sort a given set of input Pin
benkazy101415-Oct-12 1:36
benkazy101415-Oct-12 1:36 
QuestionRe: having problems with program to merge sort a given set of input Pin
Eddy Vluggen15-Oct-12 2:16
professionalEddy Vluggen15-Oct-12 2:16 
AnswerRe: having problems with program to merge sort a given set of input Pin
benkazy101415-Oct-12 2:38
benkazy101415-Oct-12 2:38 
GeneralRe: having problems with program to merge sort a given set of input Pin
Eddy Vluggen15-Oct-12 2:47
professionalEddy Vluggen15-Oct-12 2:47 
benkazy1014 wrote:
Error 8 Variable temp, m1 and m2 hides a variable in an enclosing block.

That means that you already have a variable called "m1" (and another m2) outside of that loop; that gets very confusing when reading code. It's best to give them descriptive names. Can you paste the offending block here? Perhaps we can rewrite it a bit Smile | :)

--edit; you already posted the code, that's what got this whole thing started. My mistake, I'm doing some things simultaneous. To the code, and first error;
VB
Private Sub BTN_SORT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_SORT.Click
    Dim arrayofinput()
    Dim low As Integer
    Dim high As Integer
    Dim length As Integer
    Dim middle As Integer
    Dim temp As Integer
    Dim m1 As Integer ' You declare m1 here
    Dim m2 As Integer
    If low >= high Then Return
    Dim length As Integer = high - low + 1
    Dim middle As Integer = Math.Floor((low + high) / 2)
    Do(arrayofinput, low, middle)
        Do(arrayofinput.Length, middle + 1, high)
            Dim temp(arrayofinput.Length - 1) As Integer
            For i As Integer = 0 To length - 1
                temp(i) = arrayofinput(low + i)
            Next
            Dim m1 As Integer = 0 ' means you shouldn't declare it here anew.
                                  ' if it needs be zero here, just assign zero;
                                  ' m1 = 0
            Dim m2 As Integer = middle - low + 1 ' same here, a variable with this name 
                                                 ' already exists; use another name, or
                                                 ' assign the value without declaring a variable
            For i As Integer = 0 To length - 1
                If m2 <= high - low Then
                    If m1 <= middle - low Then
                        If temp(m1) > temp(m2) Then
                            arrayofinput(i + low) = temp(m2)
                            m2 += 1
                        Else
                            arrayofinput(i + low) = temp(m1)
                            m1 += 1
                        End If
                    Else
                        arrayofinput(i + low) = temp(m2)
                        m2 += 1
                    End If
                Else
                    arrayofinput(i + low) = temp(m1)
                    m1 += 1
                End If
            Next
            ListBox2.Items.Add(ListBox1.Items.Add(input))
End Sub

That's one. The second problem is that your loop does not conform the standard. If you insert a "do" statement, rules require a "loop" statement (see docs[^]). As it is now, the compiler will not recognize where your loop ends (despite the indentation).

Once you got those two fixed, we'll move to the rest Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
if you can't read my code, try converting it here[^]

AnswerRe: having problems with program to merge sort a given set of input Pin
benkazy101415-Oct-12 1:38
benkazy101415-Oct-12 1:38 
GeneralRe: having problems with program to merge sort a given set of input Pin
Member 132474409-Jun-17 17:20
Member 132474409-Jun-17 17:20 
Question[SOLVED] How to update Gridview with value textbox = Null Pin
zaimah14-Oct-12 22:25
zaimah14-Oct-12 22:25 
AnswerRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen15-Oct-12 0:48
professionalEddy Vluggen15-Oct-12 0:48 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah15-Oct-12 5:46
zaimah15-Oct-12 5:46 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen15-Oct-12 6:13
professionalEddy Vluggen15-Oct-12 6:13 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah15-Oct-12 13:48
zaimah15-Oct-12 13:48 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 0:14
professionalEddy Vluggen16-Oct-12 0:14 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah16-Oct-12 2:35
zaimah16-Oct-12 2:35 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 2:42
professionalEddy Vluggen16-Oct-12 2:42 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah16-Oct-12 2:59
zaimah16-Oct-12 2:59 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 3:17
professionalEddy Vluggen16-Oct-12 3:17 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah16-Oct-12 3:50
zaimah16-Oct-12 3:50 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 4:21
professionalEddy Vluggen16-Oct-12 4:21 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah17-Oct-12 4:13
zaimah17-Oct-12 4:13 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen17-Oct-12 4:51
professionalEddy Vluggen17-Oct-12 4:51 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah17-Oct-12 5:25
zaimah17-Oct-12 5:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.