|
Hello every one
I am developing a application in VB 2005
I am using On Error Goto to handle errors.
Now my issue is that I want to handle different type of errors in a function separately.
That is like
Do some thing if the database connection is not there
Do some thing else if the data is not found
And so on
I am not able to identify the errors in that way.. I am able to displaying the error number and description provided by the error object.
Is there any way to find out or a list of error numbers available?
|
|
|
|
|
Why are you still using this totally abandoned way of error handling?!!!
Use Try...Catch instead:
<br />
Try<br />
.<br />
YourCodeHere<br />
.<br />
Catch ex1 As DataException<br />
<br />
Catch ex2 As IOException<br />
<br />
Catch ex3 As Exception<br />
<br />
Finally<br />
.<br />
.<br />
.<br />
End Try<br />
|
|
|
|
|
Why are you using On Error Goto when you have Try... Catch block in VB.NET??
|
|
|
|
|
So, in other words, you're not using the mechanism that allows you to do this, so you want to know why you can't do it ?
Anything that VB.NET gets from VB6 is almost certainly a disaster.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i want to convert some code in vb to vb .net..and i dont know how it will be. the vb code is
Screen.MousePointer = 11
i want to write in vb.net.. how we will write this code in vb.net. or in c# .net
|
|
|
|
|
You may change mouse cursor using cursor property of Form, such as –
Vb.Net-
Me.Cursor = Cursors.WaitCursor
C# -
this.Cursor = Cursors.WaitCursor;
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
My.Computer.Scree.MousePointer=Cursors.WaitCursor
|
|
|
|
|
Hello!
1)How can I reset the picturebox so it doesn't show a picture in it.
I have a code that show a picture from a certain file path in it.
Private Sub Button1_Click(..)
PictureBox1.Image = System.Drawin.Bitmap.FromFile("C:\...\PICTURES\IMAGE1.jpg ")
EndSub
I want to create a new Button that shows no image in PicureBox1?
2) I also wanted to ask how can I make local file path ( I want my program that it always looks for a certain picture in a subfolder PICTURES of parent folder PROGRAM ( ...\PROGRAM\PICTURES\ ). Now I use absolute file path and it is very usefull.
Now I use this string:
PictureBox1.Image = System.Drawin.Bitmap.FromFile("C:\..\PICTURES\IMAGE1.jpg" )<-- I want to
replace this path in brackets.
3) And I want to write a code for writing a list of file names in a specific folder like PICTURES:
Dim FileName As String
For Each FileName In My.Computer.Filesystem.GetFiles("C:\...\PICTURES\"
ListBox1.Items.Add(FileName)
Next
That's all
|
|
|
|
|
Hi
1. PictureBox.Image=something puts something as the Image. Now what would
it take to show nothing whatsoever?
2. relative paths start without a device (such as "C:"), but are relative to the current
directory, which could be anything (especially after some FileDialog operations).
A path relative to the apps EXE file should be constructed, starting with Application.StartupPath
|
|
|
|
|
Thanks for help I will see what comes out of it.
Well I wanted to ask you how can I make this error image to appear in case there is no such picture file in the path folder.
|
|
|
|
|
BOREC wrote: how can I make this error image to appear in case there is no such picture file in the path folder
Put the regular code in the try part of a try-catch, and signal any problem in the catch
part, maybe by setting PictureBox.Image=someErrorPicture (which could fail as well unless
you use an embedded image resource...).
|
|
|
|
|
Hello,
I am a newby to Visual Basic.. I have been having some problems with adding my data in my program. I am using Vb2005 and trying to use sotored procedure but h have error on run time
message error : No mapping exists from object type System.Windows.Forms.TextBox to a known managed provider native type
This is what I have so far :
Dim con As New System.Data.SqlClient.SqlConnection("Data Source=.;Initial Catalog=School;Integrated Security=True")
Dim com As New System.Data.SqlClient.SqlCommand("proce_school_info", con)
com.CommandType = CommandType.StoredProcedure
com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text)
com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text)
com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text)
com.Parameters.AddWithValue("@School_Address", Me.textBox4)
com.Parameters.AddWithValue("@School_City", Me.textBox5)
com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text)
com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer))
com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer))
com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text)
'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text)
com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text)
com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text)
com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text)
con.Open()
com.ExecuteNonQuery()
con.Close()
Ahmed hassan
|
|
|
|
|
hassanasp wrote: com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text)
com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text)
com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text)
com.Parameters.AddWithValue("@School_Address", Me.textBox4)
com.Parameters.AddWithValue("@School_City", Me.textBox5)
com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text)
com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer))
com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer))
com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text)
'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text)
com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text)
com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text)
com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text)
I've bolded two lines above. You will notice that the lines in bold are missing something that the other lines have. That is the .Text property.
And, by the way, naming your text boxes as textBox1, textBox2, etc. won't win you any friends. Please give them better names because the person that comes after you to maintain your code will curse you for it. And if you end up having to maintain the code you'll end up cursing yourself.
|
|
|
|
|
I notice that some .net programs do this -- allowing tab pages to float and dock in other places. Is this done with a 3rd party application, or can I do it through normal .net code? Perhaps this will be a new feature in 2008?
Thanks
|
|
|
|
|
I have been using a FOR loop to loop through the column indexes in an MS Access table and create a textbox and corresponding label on a form for each column. I am incrementing an index to step through all the columns in the Columns collection for the table. I had expected that looping through the columns this way would loop through the columns from left to right in the table (or possibly loop through in the order that the columns were created.) Unfortunately it seems that the index order is more random than that.
My question is: How can I change the column indexes to my liking OR loop through the columns from left to right using VB.Net? My original code is posted below.
Thanks, friends.
- Craig
DataSetColumnUpperBound = EventsNotifications.Ds_BorrowerGenInfo.Borrower_General_Info.Columns.Count - 1
'Dynamically create textboxes and labels
For TBindex = 2 To DataSetColumnUpperBound
Dim NewTB As New System.Windows.Forms.TextBox
Dim NewLbl As New System.Windows.Forms.Label
TBName = "Textbox" & TBindex
LblName = "Label" & TBindex
Me.Controls.Add(NewTB)
Me.Controls.Add(NewLbl)
NewTB.Name = TBName
NewLbl.Name = LblName
NewTB.Enabled = True
NewLbl.Enabled = True
NewTB.Visible = True
NewLbl.Visible = True
NewTB.Height = 20
NewLbl.Height = 20
NewTB.Width = 420
NewLbl.Width = 420
NewTB.Top = 85 + ((TBindex - 2) * 45)
NewLbl.Top = 70 + ((TBindex - 2) * 45)
NewTB.Left = 20
NewLbl.Left = 20
NewLbl.BackColor = Color.Transparent
NewTB.Text = EventsNotifications.Ds_BorrowerGenInfo.Borrower_General_Info.Rows(0).Item(TBindex).ToString
NewLbl.Text = EventsNotifications.Ds_BorrowerGenInfo.Borrower_General_Info.Columns(TBindex).ColumnName.ToString & ":"
NewLbl.Font = New Font(NewLbl.Font, _
NewLbl.Font.Style Or FontStyle.Bold)
AddHandler NewTB.Enter, AddressOf WhichTextBox
NewTB.ContextMenuStrip = ContextMenuStrip1
Next TBindex
"That rug really tied the room together."
modified on Tuesday, December 18, 2007 12:16:42 PM
|
|
|
|
|
Hi…
I am not sure how much will this help you, but I think there is an easier way then to change the index without going into VB.net codes…
Just change the order of fields to the way you want in the database query
Like…
Select a, b, c from tab1
To
Select c, b, a from tab1
Good luck
Nishkarsh
|
|
|
|
|
Thank you, Nishkarsh. You are absolutely right. Once I changed the SQL query it all fell into place.
"That rug really tied the room together."
|
|
|
|
|
I have written a small Windows service that consists of a Windows.Forms.Timer control.
I have set the Interval property to 30000 and also tried 100. The Tick event of the timer never seems to fire.
Protected Overrides Sub OnStart(ByVal args() As String)<br />
backupTimer.Interval = 30000<br />
backupTimer.Start()<br />
End Sub<br />
<br />
Protected Overrides Sub OnStop()<br />
backupTimer.Stop()<br />
End Sub<br />
<br />
Private Sub backupTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles backupTimer.Tick<br />
backupTimer.Stop()<br />
'Other code here<br />
backupTimer.Start()<br />
End Sub
Any help appreciated
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hi
You should use System.Timers.Timer or System.Threading.Timer instead of the System.Windows.Forms.Timer .
The System.Windows.Forms.Timer requires a MessageLoop in order to work. and the others will work without a MessageLoop
greets
M@u
|
|
|
|
|
Here is basically the only way I have been able to get the timer to fire correctly in Windows Service:
Class level variable:
Private coTimer As New System.Timers.Timer(10000)
Add a handler in "OnStart" event to the timer's elapsed event and enable it:
<br />
Protected Overrides Sub OnStart(ByVal args() As String)<br />
AddHandler coTimer.Elapsed, AddressOf coTimer_Elapsed<br />
coTimer.Enabled = True<br />
EventLog.WriteEntry("MyService Started")<br />
End Sub
Subroutine to take advantage of the timer:
<br />
Private Sub coTimer_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)<br />
EventLog.WriteEntry("Timer Fired!")<br />
End Sub
That should do the job for you.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
hi all
thnaks for previous reply
One more thing I want to ask u guys.it must be silly que.Actually I am working in vb.net2003
in my one application breakpoits works properly.but in another application ,when i debug application one quemark appear on break pt.& it does not work at all.I do't know wt happend.Can any one help me.
thanks in advance
poonam
|
|
|
|
|
Hi Poonam,
I tried to reproduce the said behavior at my end. Unfortunately, I was not able to do so. I would suggest you to please try repairing the Visual Studio, it might be possible that IDE has been corrupted.
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
hi Poonam,
Please check you are not debugging the application in Realease mode. If you want to debug an application it must be running in debug mode and not in Release mode.
Regards,
Nilesh Hapse
|
|
|
|
|
hi nilesh
plz tell me hw i know application running in debug or release mode.& hw i solve the problem.
thanks for reply
poonam
|
|
|
|
|
Hii,
Presently , i am using a property in propertygrid of type Image class to add an image to picturebox at runtime .It is showing the image . No
Problem .
Now , i am not able to get the selected image path as string . I have to save the image path, but it is returning
If Not CType(ctr, PictureBox).Image Is Nothing Then<br />
Dim filePath As String = CType(ctr, PictureBox).Image.ToString()<br />
as "System.Drawing.Bitmap"
if i use imagelocation it is returning as null exception. ' i dont want to use this one
Here, i want to get like this "C:\Documents and Settings\sriram\My Documents\My Pictures\cp.Jpg"
Thanks ,
DVS
|
|
|
|