473,384 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,384 software developers and data experts.

How can I make this into a class??

Ron
I would like to make this code into a class:

Private Sub btnAllCap_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAllCap.Click
txtOutput.Text = txtInput.Text.ToUpper

End Sub

Private Sub btnalllower_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnalllower.Click
txtOutput.Text = txtInput.Text.ToLower
End Sub

Private Sub btnReverse_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnReverse.Click
Dim string1 As String = txtInput.Text
txtOutput.Text = StrReverse(string1)
End Sub

I know that I could create a class and just use:
txtoutput.text = mystringclass(reverse) <-- for example....how do I
setup a class though I have no experiance with classes.

Mar 9 '07 #1
2 1020
Ron,

Most probably it is already in a class. A windowform is as well a class.
VB.Net has an inbuild construction which a windowsform instanced in an
object as soon as it is used.

That is the reason that you have to use me. to point to a variable in those
objects.

This sample you give is real not good to put it in an seperate class or you
should want to make your program unreadable for others. (Obfuscate while
writting).

Cor

"Ron" <pt*****@yahoo.comschreef in bericht
news:11**********************@h3g2000cwc.googlegro ups.com...
>I would like to make this code into a class:

Private Sub btnAllCap_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAllCap.Click
txtOutput.Text = txtInput.Text.ToUpper

End Sub

Private Sub btnalllower_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnalllower.Click
txtOutput.Text = txtInput.Text.ToLower
End Sub

Private Sub btnReverse_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnReverse.Click
Dim string1 As String = txtInput.Text
txtOutput.Text = StrReverse(string1)
End Sub

I know that I could create a class and just use:
txtoutput.text = mystringclass(reverse) <-- for example....how do I
setup a class though I have no experiance with classes.

Mar 9 '07 #2
Ron wrote:
I would like to make this code into a class:
What are you aiming for?

1) A "helper" class that you can [re-]use in the code under buttons?
2) A complete UserControl, complete with textbox and buttons that does
all of this (and more)?

From your last comment, I'll assume the former, which gets you ...

Import VB=Microsoft.VisualBasic

Public Class SuperString

Public Shared Function Reserve( _
ByVal sText as String _
) as String

Return VB.StrReverse( sText )
End Function

End Class

....then...

Private Sub btnReverse_Click( _
ByVal sender As System.Object _
, ByVal e As System.EventArgs _
) Handles btnReverse.Click

txtInput.Text = SuperString.Reverse( txtInput.Text)

End Sub

Note: there's no "New SuperString" anywhere because the Reverse method
is declared as "Shared".

HTH,
Phill W.
Mar 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
4
by: Florian Preknya | last post by:
I work on building a metamodel from an UML diagram (serialized as xmi). There I have a class called Class that represents a class from the UML model. The Class has a name member and ininitially it...
2
by: john smith | last post by:
Hi, I have a class like so... template<class XV, class T> class Foo { Bar<T>* b; }; and another class template<class T> class Bar { public: friend template<class XV, class T> class...
8
by: Bryan Parkoff | last post by:
I find an interesting issue that one base class has only one copy for each derived class. It looks like that one base class will be copied into three base classes while derived class from base...
5
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base...
7
by: quarup | last post by:
I want to specialize a template function that lives inside a class, but am getting a compile error in VS.net 2003. Here's my code: template <class T> class A { public: template <class U> void...
2
by: Cari Elf | last post by:
I wrote a template class that inherits from the PUG xml_tree_walker class so that I can load data from any XML file without having to write a parser for each one. template <class T> class...
2
by: Wolfgang | last post by:
Hi, I'm trying to understand how could I inherit a nested class. Say for instance - I've four classes namely class A, class B, class C, class D. class B is nested inside class A class D is...
2
by: =?ISO-8859-1?Q?Andr=E9_Luiz_Carvalho?= | last post by:
Hi there, I'm porting an application from Java to C++ / BREW so I can't use the stl, therefore, I have to implement the basic structures that the app use in Java. I'm implementing a Hashtable...
3
by: puzzlecracker | last post by:
Would you quickly remind me the difference between, regular class, static class, and nested class? Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.