Re: functions help

  • From: "black ares" <matematicianu2003@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 19 Sep 2009 15:43:24 +0300

as I said, you have done that course for nothing.
who said you that  you will do something in programming?
You have done a vb course, you have done a c++ course, but you don't know nothing! Because you didn't tried even to learn something, you have done your assessments with help from other, copying your answers enterely from them.
If you want a good advice, stop trying to do something in programming.
Try other thing may be you will have a little more success.
But if you don't learn, you will never know anything.

----- Original Message ----- From: "StarTrekCafe" <startrekcafe@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, September 19, 2009 2:43 PM
Subject: Fwd: functions help


--- In helpwithvb@xxxxxxxxxxxxxxx, "Marvin Hunkin" <startrekcafe@...> wrote:

Hi .
did a course in visual basic at a college in south Australia in 2008 ,
Australia.
And a blind programming student using the jaws for windows screen reader
from http://www.freedomscientific.com

well had forgotten a lot of what i learnt in vb.
and now a lot of the examples in the course got corrupted.
and only my final project survived.
now.
a blind friend and i developing a star trek application using visual web
developer 2008 express and sql server and management studio 2008 express.
and he had written quite a lot of articles and will post on
http://www.blindgeeks.org
but my turn to write the article.
and when i got to advanced sql.
for using data tables got a bit stuck.
so created a test site and some quizzes.
but now, he is abandoing me.
as i am struggling to complete this third quiz.
the third quiz is to create a function, which takes two parameters and adds
the two numbers and returns the two numbers .
in vwd.
in the website and a message to show the two integers passed and the final
result.
Rick thomas says he is the guy who is helping me to learn my vb education on
my own.
so will paste the vb class, the markup for the page and the sub module click
event code.
he says that i am calling it incorrect.
can you please help.
if you are still up tonight.
or over the weekend.
please reply asap.
and help me out.
until i can figure this quiz out.
he says the star trek series is off, until i have a better understanding of
vb, and functions, sub, and parameters.
have been reading some tutorials on line.
please help me out if possible.
at a loss.
cheers Marvin.

Imports Microsoft.VisualBasic

Public Class TestClass1

' Public sub for Hello World Goes here.
Public Sub HelloWorld()
' User Message goes Here.
UserMsg.Show("Hello World")
End Sub
Public Sub DisplayParms (ByVal PassedMessage As string )
' User Msg goes here.
UserMsg.Show("PassedMessage Variable " & PassedMessage)
End Sub
Public Function AddTwoNumbers(ByVal  PassedInt1 As Integer, ByVal
PassedInt2 As Integer) As Integer

' Declare Variables.

Dim answer As Integer = 0

' User Message for PassedInt1.
UserMsg.Show("PassedInt1 " & PassedInt1)
' User Message for PassedInt2.
UserMsg.Show("PassedInt2 " & PassedInt2)

' Return answer.
answer = PassedInt1 + PassedInt2
' User Message for answer.
UserMsg.Show("Answer is " & answer)
Return answer
end function

End Class

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>
<head runat="server">
   <title></title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
<asp:Button runat="server" Text="Display" ID="Button1" />
   </div>
   </form>
</body>
</html>


Partial Class _Default
   Inherits System.Web.UI.Page

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

' Declare Variables.
' Instantiate a copy of the class.
' Call the sub routine.
Dim PassedInt1 As Integer = 2
Dim PassedInt2 As Integer = 2
Dim TestClass1 As TestClass1
TestClass1 = New TestClass1()
TestClass1.HelloWorld()
TestClass1.DisplayParms("Hello world")
TestClass1.AddTwoNumbers(PassedInt1, PassedInt2 )
End Sub
End Class

and here's the user msessage, the global code module and a logger module.
Public Class Globals
' Function:
' This Class  holds global constants and variables so no need to
Instantiate.
Public Shared RootPath  As String = ""

Imports Microsoft.VisualBasic
Imports System.Configuration
Public Class Logger
' Private Shared Inst As Logger = New Logger

Public Shared Sub WriteLine(ByVal Line As String)
Dim Filename As String
filename = "c:\TestSite\Logger.txt"
Dim objWriter As New System.IO.StreamWriter(Filename, True)
Try
If Not objWriter Is Nothing Then
objWriter.WriteLine(Line)
End If
Catch ex As Exception
End Try
objWriter.Close()
objWriter.Dispose()
End Sub
Public Shared Sub Clear()
Dim filename As String
filename = "c:\TestSite\Logger.txt"
' filename = Globals.RootPath & _
' System.Configuration.ConfigurationManager.AppSettings("LoggerPath")
Dim Sw As System.IO.StreamWriter
Sw = new System.IO.StreamWriter(filename)
Sw.WriteLine(" Newly Created:")
Sw.WriteLine( "")
Sw.Close()
Sw.Dispose()

End Sub

End Class

Imports Microsoft.VisualBasic
Public Class UserMsg
Public Shared Sub Show(ByVal Message As String)
System.Web.HttpContext.Current.Response.Write( _
"<SCRIPT LANGUAGE=""JavaScript"">" _
& vbCrLf)
System.Web.HttpContext.Current.Response.Write( _
"alert(""" & Message & """)" _
& vbCrLf)
       System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End Sub

End Class

End Class


----- Original Message ----- From: "RicksPlace" <ofbgmail@...>
To: "Marvin Hunkin" <startrekcafe@...>
Sent: Friday, September 18, 2009 8:58 PM
Subject: Re: quiz 3 success


The following is not a correct call to a function. It demonstrates that you
do not understand the diference between a Subroutine and a Function even
though I just told you in the most simple terms I could. You will have to
continue your VB education on your own until you can use functions and
subroutines well. When you get there let me know and I will give you some
more quizs to make sure you understand them so I don't have to go through
trying to teach you Visual Basic on top of VWD. Then we can continue with
the series if I am not off into another project by then.
TestClass1.AddTwoNumbers(PassedInt1, PassedInt2 )
The above statement is incorrect.
End Sub
----- Original Message ----- From: "Marvin Hunkin" <startrekcafe@...>
To: "RicksPlace" <ofbgmail@...>
Sent: Friday, September 18, 2009 6:43 AM
Subject: Re: quiz 3 success


       hi.
here's the click event module.
is that what you are looking for.
if not please explain exactly what you want.
not a mind reader.
Marvin.


Partial Class _Default
   Inherits System.Web.UI.Page

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

' Declare Variables.
' Instantiate a copy of the class.
' Call the sub routine.
Dim PassedInt1 As Integer = 2
Dim PassedInt2 As Integer = 2
Dim TestClass1 As TestClass1
TestClass1 = New TestClass1()
TestClass1.HelloWorld()
TestClass1.DisplayParms("Hello world")
TestClass1.AddTwoNumbers(PassedInt1, PassedInt2 )
End Sub
End Class


----- Original Message ----- From: "RicksPlace" <ofbgmail@...>
To: "Marvin Hunkin" <startrekcafe@...>
Sent: Friday, September 18, 2009 7:32 PM
Subject: Re: quiz 3 success


OK, here is the story. You use a functiion for a diferent reason than a
Subroutine. A subroutine is a block of code you want to execute that does
something like read a file or write a file or other things. A function is
a
block of code you call when you want to get something like a value
returned
to the calling module. A function returns a value to the calling module
while a subroutine does not return a value to the calling subroutine.
Functions are things that do something and return something. Most math
functions are functions like to get the square root of a number or other
built-in functions. Your problem did not require anything except to
specify
the parameters to pass into your function. Both Subroutines and Functiions
can receive parameters. The parameter list in the calling module must
match
the parameter list in the called module. Now. Please display the result of
your function in the click event and send me the code for the click event
when done.
I will not do any more explanations on this subject unless we get into
more
depth with functions and subs related to the project.
Rick
----- Original Message ----- From: "Marvin Hunkin" <startrekcafe@...>
To: "RicksPlace" <ofbgmail@...>
Sent: Friday, September 18, 2009 5:11 AM
Subject: Re: quiz 3 success


       hi.
well tell me how to get it to work.
thought i had.
let me know.
i am not a mind reader.
please let me know what you meant.
had to copy the function definition from that web site page.
so not sure why i was getting errors.
if i called the function straight from the click event was getting
errors.
so tell me how to get it right and to fix it right.
i am not a mind reader.
sorry.
i have disapointed you.
Marvin.
----- Original Message ----- From: "RicksPlace" <ofbgmail@...>
To: "Marvin Hunkin" <startrekcafe@...>
Sent: Friday, September 18, 2009 6:15 PM
Subject: Re: quiz 3 success


Marv: You are not using the variable you return to the click event. the
idea
behind a function is that you call it to get something.In you r click
event
display the result of the calculation.
----- Original Message ----- From: "Marvin Hunkin" <startrekcafe@...>
To: "RicksPlace" <ofbgmail@...>
Sent: Friday, September 18, 2009 1:11 AM
Subject: quiz 3 success


hi.
do not know why i was getting those errors.
so went to the home work site and copied the private function
definition.
changed it to public.
now got the quiz working.
it gives me the correct answer.
so got it working at last.
glad about that.
able to pass 2 variables .
cheers Marvin.

ps: was able to figure this on my own eventually.
at least learning to debug my code.

Imports Microsoft.VisualBasic

Public Class TestClass1

' Public sub for Hello World Goes here.
Public Sub HelloWorld()
' User Message goes Here.
UserMsg.Show("Hello World")
End Sub
Public Sub DisplayParms (ByVal PassedMessage As string )
' User Msg goes here.
UserMsg.Show("PassedMessage Variable " & PassedMessage)
End Sub
Public Function AddTwoNumbers(ByVal  PassedInt1 As Integer, ByVal
PassedInt2 As Integer) As Integer

' Declare Variables.

Dim answer As Integer = 0

' User Message for PassedInt1.
UserMsg.Show("PassedInt1 " & PassedInt1)
' User Message for PassedInt2.
UserMsg.Show("PassedInt2 " & PassedInt2)

' Return answer.
answer = PassedInt1 + PassedInt2
' User Message for answer.
UserMsg.Show("Answer is " & answer)
Return answer
end function

End Class

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>
<head runat="server">
   <title></title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
<asp:Button runat="server" Text="Display" ID="Button1" />
   </div>
   </form>
</body>
</html>


Partial Class _Default
   Inherits System.Web.UI.Page

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

' Declare Variables.
' Instantiate a copy of the class.
' Call the sub routine.
Dim PassedInt1 As Integer = 2
Dim PassedInt2 As Integer = 2
Dim TestClass1 As TestClass1
TestClass1 = New TestClass1()
TestClass1.HelloWorld()
TestClass1.DisplayParms("Hello world")
TestClass1.AddTwoNumbers(PassedInt1, PassedInt2 )
End Sub
End Class










--- End forwarded message ---


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: