Click here to Skip to main content
15,893,722 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Runtime Creation Of Button+Adding Events+Sourabh Pin
pmarfleet3-Nov-07 23:05
pmarfleet3-Nov-07 23:05 
AnswerRe: Runtime Creation Of Button+Adding Events+Sourabh Pin
Christian Graus3-Nov-07 12:19
protectorChristian Graus3-Nov-07 12:19 
QuestionPassing argument to function Pin
csinva3-Nov-07 8:36
csinva3-Nov-07 8:36 
AnswerRe: Passing argument to function Pin
pmarfleet3-Nov-07 9:03
pmarfleet3-Nov-07 9:03 
GeneralRe: Passing argument to function Pin
csinva3-Nov-07 9:12
csinva3-Nov-07 9:12 
GeneralRe: Passing argument to function Pin
pmarfleet3-Nov-07 9:21
pmarfleet3-Nov-07 9:21 
AnswerRe: Passing argument to function Pin
Guffa3-Nov-07 9:27
Guffa3-Nov-07 9:27 
AnswerRe: Passing argument to function Pin
Guffa3-Nov-07 9:12
Guffa3-Nov-07 9:12 
I made corrections in the code and started to write comments, but I had to put number references in the comments, and the notes separately:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

   Dim name as String = "Joe"
   Dim Userid as Integer

   ' 1, 2, 3 
   Userid = GetUserID(name)

   ' 4, 5
   txtUserid.Text = Userid.ToString()

End Sub

' 6
Public Function GetUserID(ByVal name As String) As Integer

   .... datbase connection stuff
   .... userid as int32 in database

   sUserID = Convert.ToInt32(myCommand.ExecuteScalar())

   ' 7
   ' Return

   ' 8
   ' Result_sUserID = sUserID

   ' 9
   Return sUserID

End Function


1. You were trying to use the variable Userid by the name result_sUserID. If you use the same name for the same variable, you will find that the compiler is much more cooperative.

2. Sending the value of the variable Userid to the function doesn't make it possible for the function to return a value to the variable.

3. The function returns a value, you should assign that value to the variable.

4. You got it backwards. You should assign the value of the variable to the Text property of the control, not the other way around.

5. The Text property is a string value, so you should convert the integer value to a string.

6. Remove the integer argument from the function.

7. You are returning from the function before assigning a return value. The rest of the code would not be executed.

8. Assigning a value to one of the arguments of the function doesn't change the variable from where the value was taken that was sent to the function.

9. Use the Return statement to set the return value of the function.


Experience is the sum of all the mistakes you have done.

GeneralRe: Passing argument to function Pin
csinva3-Nov-07 9:56
csinva3-Nov-07 9:56 
GeneralRe: Passing argument to function Pin
csinva3-Nov-07 10:29
csinva3-Nov-07 10:29 
AnswerRe: Passing argument to function Pin
Guffa3-Nov-07 11:22
Guffa3-Nov-07 11:22 
Question[Message Deleted] Pin
Unknown Ajanabi3-Nov-07 2:42
Unknown Ajanabi3-Nov-07 2:42 
AnswerRe: i want to know how to create page dynamically like Sulekha.com Pin
Malcolm Smart3-Nov-07 4:23
Malcolm Smart3-Nov-07 4:23 
AnswerRe: i want to know how to create page dynamically like Sulekha.com Pin
Mircea Grelus3-Nov-07 5:15
Mircea Grelus3-Nov-07 5:15 
GeneralRe: i want to know how to create page dynamically like Sulekha.com Pin
Paul Conrad3-Nov-07 5:22
professionalPaul Conrad3-Nov-07 5:22 
Questionajax.net Pin
Rinki Mukheraji3-Nov-07 1:19
Rinki Mukheraji3-Nov-07 1:19 
AnswerRe: ajax.net Pin
InsDev3-Nov-07 1:33
InsDev3-Nov-07 1:33 
GeneralRe: ajax.net Pin
Rinki Mukheraji3-Nov-07 1:49
Rinki Mukheraji3-Nov-07 1:49 
AnswerRe: ajax.net Pin
Mircea Grelus3-Nov-07 2:10
Mircea Grelus3-Nov-07 2:10 
AnswerRe: ajax.net Pin
Unknown Ajanabi3-Nov-07 2:34
Unknown Ajanabi3-Nov-07 2:34 
AnswerRe: ajax.net Pin
Braulio Dez3-Nov-07 6:20
Braulio Dez3-Nov-07 6:20 
Questionform closing event Pin
Sonia Gupta3-Nov-07 1:00
Sonia Gupta3-Nov-07 1:00 
AnswerRe: form closing event Pin
InsDev3-Nov-07 1:30
InsDev3-Nov-07 1:30 
GeneralRe: form closing event Pin
Sonia Gupta3-Nov-07 1:42
Sonia Gupta3-Nov-07 1:42 
GeneralRe: form closing event Pin
Mircea Grelus3-Nov-07 2:05
Mircea Grelus3-Nov-07 2:05 

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.