?
Solved

emergency simple "for"

Posted on 2005-04-16
11
Medium Priority
?
197 Views
Last Modified: 2010-04-23
j and x does not increasing can you fix the code.  

Private Sub btnGrupolustur_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrupolustur.Click
        Dim num, telno, i, j, x As Long
        j = 0
        x = 0
        Try
            Me.conn.Open()
            For i = 5052400000 To 5059000000 Step 100
                j = j + 1
                If j = 100 Then
                    x = x + 1
                End If
                Response.Write("505 groupno " & x & "<br>")
            Next
        Catch ex As Exception
            Me.lbleEx.Text = ex.Message
        Finally
        End Try
    End Sub
0
Comment
Question by:orhanbaba
  • 6
  • 4
11 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 13796859
x will increase only once,

what do you exactly want to achieve??

Is it this:

Dim i As Long = 0
Dim j As Long = 0
Dim x As Long = 0
Dim sb As New System.Text.StringBuilder()
Try
      For i = 5052400000 To 5059000000 Step 100
            j += 1
            'every 100 instance, increase x
            If (j Mod 100) = 0  Then
                  x += 1
            End If
            sb.AppendFormat("<div>505 groupno: {0}</div>",x)
      
      Next
Catch ex As Exception
      Me.lbleEx.Text = ex.Message
Finally
      Response.Write(sb.ToString())
End Try
0
 
LVL 12

Accepted Solution

by:
S-Twilley earned 2000 total points
ID: 13796865
Im not sure what you're trying to achieve.... but should it be something like this:

Private Sub btnGrupolustur_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrupolustur.Click
        Dim num, telno, i, j, x As Long
        j = 0
        x = 0
        Try
            Me.conn.Open()
            For i = 5052400000 To 5059000000 Step 100
                j = j + 1
                If j = 100 Then
                    x = x + 1
                    j = 0
                End If
                Response.Write("505 groupno " & x & "<br>")
            Next
        Catch ex As Exception
            Me.lbleEx.Text = ex.Message
        Finally
        End Try
    End Sub

=====================

Question:  Is the variable J meant to be used in the response as well... or just used to increment X.

You might get a better solution if you explain what you're trying to achieve within you code, and could then be given an alternative
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796866
Ooops... i was a bit slow there :P..  i'll get off your toes!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:b1xml2
ID: 13796908
<G>
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796921
you should have awarded b1xml2 the points for this question, or at least split them... the answer's give the same result... and mine was actually later.

try and remember that for next time please orhanbaba
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13796940
thanks S-Twilley for that.. I'll just blacklist this user. I am really not so much into the points as into imparting understanding...
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13796943
Well... bit of fun with the points and everything... but just felt you deserved credit for your efforts.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13796948
understood =)
0
 
LVL 4

Author Comment

by:orhanbaba
ID: 13801551
these answers may give same results but S-Twilley 's code was the code i was  looking for. this code i pasted here is not a part of real code of my project.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13801662
sorry orhanbaba, but the code from me and Twilley amounted to the same. In fact one could argue that the code from em is better because the j value is retained whilst the rest of the functionality is exactly the same as what twilley put.

Even he knows that the code is EXACTLY the same in features. So if you wish to lie, do that at your own spare time. We are not naive.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13801836
as such, you are blacklisted by me forever
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question