Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.


avoid using goto


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-11-2007, 11:56 AM
Junior Member
 
Join Date: Aug 2007
Location: The netherland, Geldrop
Posts: 23
Default avoid using goto

As a reaction on some code I see. As in the help-example the goto can give unpredictable results. The code will be verry difficult to debug. Tip: don't use labels other then an errorlabel. Let the sub do just one single task, so you can call the entire sub in recursive.

example
Sub btnDCRecSave_Click
' pre het keyfield is uniek
' post waardes worden weggescheven in de geheugentabel

If KeyFieldUnique(date) = true Then
RecordSave(...........)
Else
lvYesNo =Msgbox("date already exists. Delete existing record??")," ",cmsgboxYesNo,cMsgBoxQuestion)
If lvYesNo =cYes Then
smnuDCRecDelete_Click 'RecordDelete(aTable) <-- delete the record that has the same keyfield
gv_tbl_mutaties = true
gv_rec_Mutaties = false
btnDCRecSave_Click 'recursieve call <--- checks again the keyfield if it is unique
End If
End If

Last edited by paul j : 11-11-2007 at 12:03 PM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoid starting a program after a given time Arrie Questions & Help Needed 2 05-31-2008 09:06 AM
Probleme bei device.exe wegen goto-Befehl urgott German Forum 13 01-24-2008 09:01 AM
Goto problem klaus Questions & Help Needed 2 11-15-2007 01:28 PM
Error when loading table how to avoid tvrman Questions & Help Needed 2 08-04-2007 08:32 PM
Quick question to avoid going down a long dead end route LineCutter Questions & Help Needed 2 05-22-2007 07:29 AM


All times are GMT. The time now is 07:21 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0