|
leostalin91 wrote: When i use large resolution image(height and width of the image is more)it hang and not respond.how rectify this or set progress bar until the loop ends.
Would need to be executed on it's own thread, otherwise the UI-thread does not get the chance to repaint. The easiest way to do so, and add a progressbar, is using a BackgroundWorker [^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
i think, you can add Application.doevents in u looping..
|
|
|
|
|
i think, you can add Application.doevents in ur looping..
|
|
|
|
|
That's the most dangerous way to do it as DoEvents will allow you to click other buttons and possibly make the code reentrant.
The appropriate method is to farm the work off to a background thread.
|
|
|
|
|
I agree with Dave you need to process this on a background thread so the UI can update itself.
|
|
|
|
|
Hello. I am getting this stack overflow exception.
I have tried different things like:
- making the current class Shared
- or using a counter to see if the class already has an instance?
But none of them is working for me. Here is what I am trying ( read comments as well )
Imports SomeLibrary
---------------------------------
Public Class ABC
Private WithEvents instance As New ClassName
Public Sub New()
End Sub
End Class
So how can I get better of this exception? Thanks.
This world is going to explode due to international politics, SOON.
modified 16-Oct-12 4:04am.
|
|
|
|
|
You have a circular reference somewhere; does the class 'ClassName' from imported DLL have a reference to class 'ABC'?
|
|
|
|
|
So it appears that VS2012 does not use the same methodology to generate installations as VS2008. Fine, so be it, I will play along. After converting a project from VS2008 to VS2012, the solution explorer had my project and the install project I had created in VS 2008, the install marked as incompatible.
I downloaded the InstallShield Limited edition, installed it. All is fine.
I removed the old (incompatible) installation from my solution list (right click, remove from solution). When I did this my solution list appears to have disappeared and I only have my application left. According to the InstsallShield instructions I am to right click on my solution and add a new project, but I do not appear to have a solution any more, just my project.
Any idea how to get it back? The solution group, so I can have both the app and the install in there like I used to.
One thought was to create a new solution then add my project to it, but I do not see how to do that.
Thanks in advance
no-e
Updated: Never mind, found it, there is a setting on the options page to show the solution.
modified 15-Oct-12 13:08pm.
|
|
|
|
|
The Solution is there. If there's only one project in the solution it's hidden in Solution Explorer by default.
The fix this, go to Tools -> Options... -> Projects and Solutions on the left. In the right pane, check the box that says "Always show solution".
Done.
|
|
|
|
|
please i am having problems writing a program to merge sort using vb.net2010. here is my code any form of help will be appreciated.
i am also having problems outputing the sorted result into listbox2
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
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
Dim m2 As Integer = middle - low + 1
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
|
|
|
|
|
benkazy1014 wrote: please i am having problems writing a program to merge sort using vb.net2010. here is my code any form of help will be appreciated.
i am also having problems outputing the sorted result into listbox2
We'll need more description of the problem; does it generate an exception? If yes, what did the message say?
Does it compile? Does it run? If yes, upto where? Did it error at all, or does it just generate a different output than expected?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
If it does not compile, you'll get a compiler-error. What does the error say?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Error 8 Variable temp, m1 and m2 hides a variable in an enclosing block.
do must end with a matchin loop.
temp is not an array,expression not a method
and a whole lot of errors . although it accepts inputs, it does not sort.have you ever tried anything on this topic? if yes how did you go about it. i am desperately in need of help. thank you.
|
|
|
|
|
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
--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;
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
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
Dim m2 As Integer = middle - low + 1
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
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
can you please help me with code in vb.net
|
|
|
|
|
you'll have to modify this code to suit your needs, but this is how I sort/merge text files.
m& = LBOUND(Master)
s& = LBOUND(Slave)
t& = 0
DO
IF m& < MasterLines& THEN '* aka not eof(masterfile%)
IF s& < SlaveLines& THEN '* aka not eof(slavefile%)
IF Master(m&) > Slave(s&) THEN '* reached end of primary so flush secondary
printToFile Slave(s&), OChannel%, s&, t&
ELSE
printToFile Master(m&), OChannel%, m&, t&
END IF
ELSE
printToFile Master(m&), OChannel%, m&, t&
END IF
ELSE
IF s& < SlaveLines& THEN
printToFile Slave(s&), OChannel%, s&, t&
ELSE
EXIT DO
END IF
END IF
LOOP
CLOSE OChannel%
PRINT MasterLines& " lines merged from Master file "; Mast$
PRINT SlaveLines& " lines merged from Slave file "; Slav$
PRINT t& " Records written to "; OutPF$
DO
LOOP UNTIL INKEY$ > ""
SYSTEM
SUB printToFile (x$, channel%, RecsPrinted&, t&)
t& = t& +1 '* increment the appropriate array counter
RecsPrinted& = RecsPrinted& + 1 ' keep track of how many processed so far
PRINT #channel%, x$
END SUB
SUB MergeSort (array() AS STRING, start&, finish&)
IF start& < finish& THEN '* no need to do this for 0-sized sublists
length& = finish& - start& + 1
middle& = start& + (finish& - start&) \ 2
MergeSort array(), start&, middle&
MergeSort array(), middle& + 1, finish&
REDIM temp(0 TO length& - 1) AS STRING
FOR i& = 0 TO length& - 1
temp(i&) = array(start& + i&)
NEXT
mptr& = 0
sptr& = middle& - start& + 1
FOR i& = 0 TO length& - 1
IF sptr& > finish& - start& THEN
array(i& + start&) = temp(mptr&)
mptr& = mptr& + 1
ELSE
IF mptr& > middle& - start& THEN
array(i& + start&) = temp(sptr&)
sptr& = sptr& + 1
ELSE
IF temp(mptr&) > temp(sptr&) THEN
array(i& + start&) = temp(sptr&)
sptr& = sptr& + 1
ELSE
array(i& + start&) = temp(mptr&)
mptr& = mptr& + 1
END IF
END IF
END IF
NEXT
ERASE temp
END IF
END SUB
|
|
|
|
|
Hi, its been years i don't do vb. So its like im a junior in this. I have problem update my Gridview. My gridview is to update marks for student. The problem is, the update have problem if the textbox is with a NULL value. If i put 0 in the textbox, the update runs ok.
This is my gridview html
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
<Columns>
<asp:TemplateField HeaderText="Student ID" SortExpression="stID">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Width="50px" Text='<%# Bind("stID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO1" SortExpression="CO1">
<ItemTemplate>
<asp:TextBox ID="Label1" runat="server" Width="50px" Text='<%# Bind("CO1") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO2" SortExpression="CO2">
<ItemTemplate>
<asp:TextBox ID="Label2" runat="server" Width="50px" Text='<%# Bind("CO2") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO3" SortExpression="CO3">
<ItemTemplate>
<asp:TextBox ID="Label3" runat="server" Width="50px" Text='<%# Bind("CO3") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO4" SortExpression="CO4">
<ItemTemplate>
<asp:TextBox ID="Label4" runat="server" Width="50px" Text='<%# Bind("CO4") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO5" SortExpression="CO5">
<ItemTemplate>
<asp:TextBox ID="Label5" runat="server" Width="50px" Text='<%# Bind("CO5") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO6" SortExpression="CO6">
<ItemTemplate>
<asp:TextBox ID="Label6" runat="server" Width="50px" Text='<%# Bind("CO6") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO7" SortExpression="CO7">
<ItemTemplate>
<asp:TextBox ID="Label7" runat="server" Width="50px" Text='<%# Bind("CO7") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO8" SortExpression="CO8">
<ItemTemplate>
<asp:TextBox ID="Label8" runat="server" Width="50px" Text='<%# Bind("CO8") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO9" SortExpression="CO9">
<ItemTemplate>
<asp:TextBox ID="Label9" runat="server" Width="50px" Text='<%# Bind("CO9") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CO10" SortExpression="CO10">
<ItemTemplate>
<asp:TextBox ID="Label10" runat="server" Width="50px" Text='<%# Bind("CO10") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="White" ForeColor="#330099" />
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<HeaderStyle BorderColor="Maroon" BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:UTMConnectionString %>"
SelectCommand="SELECT [stID], [CO1], [CO2], [CO3], [CO4], [CO5], [CO6], [CO7], [CO8], [CO9], [CO10] FROM [quiz] WHERE ([Cid] = @Cid)">
<SelectParameters>
<asp:SessionParameter Name="Cid" SessionField="CourseID" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
The erros is on line:
Quote: Dim C1 As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text
This error will happen if i didn't put any values in the text box.. The error will be:
[FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +205
Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) +101
[InvalidCastException: Conversion from string "" to type
Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) +259
My button to update my gridview..
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rowcollect As GridViewRowCollection = GridView1.Rows
Dim index As Integer = GridView1.SelectedIndex
Dim cd As String = Session("CourseID")
Dim id As String = Session("userID")
Dim totQuiz, totC1, totC2, totC3, totC4, totC5 As Integer
Dim totC6, totC7, totC8, totC9, totC10 As Integer
For Each row As GridViewRow In rowcollect
Dim C1 As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text
Dim C2 As Integer = DirectCast(row.FindControl("Label2"), TextBox).Text
Dim C3 As Integer = DirectCast(row.FindControl("Label3"), TextBox).Text
Dim C4 As Integer = DirectCast(row.FindControl("Label4"), TextBox).Text
Dim C5 As Integer = DirectCast(row.FindControl("Label5"), TextBox).Text
Dim C6 As Integer = DirectCast(row.FindControl("Label6"), TextBox).Text
Dim C7 As Integer = DirectCast(row.FindControl("Label7"), TextBox).Text
Dim C8 As Integer = DirectCast(row.FindControl("Label8"), TextBox).Text
Dim C9 As Integer = DirectCast(row.FindControl("Label9"), TextBox).Text
Dim C10 As Integer = DirectCast(row.FindControl("Label10"), TextBox).Text
Dim sID As String = DirectCast(row.FindControl("Label11"), Label).Text
If row.RowType = DataControlRowType.DataRow Then
If index = -1 Then
index = 0
End If
For i As Integer = 1 To row.Cells.Count - 1
Dim conn As New SqlConnection(ConfigurationManager.AppSettings("strConn"))
Dim MySQL As String = "UPDATE quiz SET CO1=@c1,CO2=@c2,CO3=@c3,CO4=@c4,CO5=@c5,CO6=@c6,CO7=@c7,CO8=@c8,CO9=@c9,CO10=@c10 WHERE CourseID=@cID AND stID=@id"
Dim cmd As SqlCommand = New SqlCommand(MySQL, conn)
cmd.Parameters.AddWithValue("@cID", cd.Trim)
cmd.Parameters.AddWithValue("@id", sID)
cmd.Parameters.Add(New SqlParameter("@c1", SqlDbType.Int, 4))
cmd.Parameters("@c1").Value = Convert.DBNull(C1)
totC1 += C1
cmd.Parameters.Add(New SqlParameter("@c2", SqlDbType.Int, 4))
cmd.Parameters("@c2").Value = C2
totC2 += C2
cmd.Parameters.Add(New SqlParameter("@c3", SqlDbType.Int, 4))
cmd.Parameters("@c3").Value = C3
totC3 += C3
cmd.Parameters.Add(New SqlParameter("@c4", SqlDbType.Int, 4))
cmd.Parameters("@c4").Value = C4
totC4 += C4
cmd.Parameters.Add(New SqlParameter("@c5", SqlDbType.Int, 4))
cmd.Parameters("@c5").Value = C5
totC5 += C5
cmd.Parameters.Add(New SqlParameter("@c6", SqlDbType.Int, 4))
cmd.Parameters("@c6").Value = C6
totC6 += C6
cmd.Parameters.Add(New SqlParameter("@c7", SqlDbType.Int, 4))
cmd.Parameters("@c7").Value = C7
totC7 += C7
cmd.Parameters.Add(New SqlParameter("@c8", SqlDbType.Int, 4))
cmd.Parameters("@c8").Value = C8
totC8 += C8
cmd.Parameters.Add(New SqlParameter("@c9", SqlDbType.Int, 4))
cmd.Parameters("@c9").Value = C9
totC9 += C9
cmd.Parameters.Add(New SqlParameter("@c10", SqlDbType.Int, 4))
cmd.Parameters("@c10").Value = C10
totC10 += C10
totQuiz = C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 + C9 + C10
cmd.Parameters.Add(New SqlParameter("@total", SqlDbType.Int, 4))
cmd.Parameters("@total").Value = totQuiz
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Next
End If
Next
totCO(totC1, totC2, totC3, totC4, totC5, totC6, totC7, totC8, totC9, totC10)
End Sub
I try to put value '0' if the text box = Null, but it didn't work.
Its been few days I've been trying to find answers. Hope someone can suggest any idea for me to solve this.
modified 31-Oct-12 7:11am.
|
|
|
|
|
zaimah wrote: I try to put value '0' if the text box = Null, but it didn't work.
Its been few days I've been trying to find answers. Hope someone can suggest any idea for me to solve this.
From
Dim C1 As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text
To
Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text
Dim C1 As Integer = Convert.ToInt32(C1S)
That should do it
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
It didn't work with the same error. before this, the error is at:
Dim C1 As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text
after i edit using your suggestion, the error is at:
Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text
its as if it didn't even reach the convert part, the error occurred.. I have try similar method, trying to convert the value so that it can update the value Null to my table, but the error is still at the find control.. Is there something wrong with my coding at find control part? But the update is successful, except when the value is NULL..
This really gives me a headache.. Thanks for replying my question
Is there any solution?
|
|
|
|
|
zaimah wrote: its as if it didn't even reach the convert part, the error occurred..
Put a breakpoint there and find out if it does, or does not execute.
zaimah wrote: Is there something wrong with my coding at find control part?
That wouldn't change due to a value being empty, would it?
Didn't notice before, but you're looking for Label1 and casting it to a TextBox . Shouldn't that be a Label you're casting to?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
the name for textbox is Label1.. Sorry for the confusion
Originally, the gridview only have edit button for each row of data in gridview. So i change my gridview in html. I change all the label to textbox and bound the text box. So i would only have one button to update everything that i key-in in the gridview. After i change the label to textbox, lazy of me, im not changing the name of the previous label
Would that effect the coding? But i can update the data. The problem is only when one of the textbox is empty. If the textbox that i cast for C10 is empty, then the error would be on C10, not C1.
|
|
|
|
|
C1 seems to be always containing NULL ; from the code you pasted;
cmd.Parameters("@c1").Value = Convert.DBNull(C1)
Shouldn't that be an integer?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Not always. If C1-C5 have value, and C6 is empty, then the error would be on C6. The weird thing is, the error only occur at textbox that are empty. It runs OK when there's no empty textbox.
|
|
|
|
|
That's not weird; you'll have to verify the users' input. If the database does not allow empty values (which it obviously doesn't), then you need to eliminate those before executing the query. It's either checking each value, or modify the database.
..you could copy the example-line, and add something similar to each parameter
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|