473,396 Members | 1,707 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,396 software developers and data experts.

I need explanation for this code pls help

Hi all,
this is my 3rd week in studying VB codes and i came across with this codes
from a online tutorial about classes.

Public Function MiddleInitial() As String
MiddleInitial = Left$(middleNameValue, 1)
End Function

Public Function MiddleInitial(ByVal period As Boolean) As String
MiddleInitial = Left$(middleNameValue, 1) & "."
End Function

The tutorial just tell me how to put the codes and its my duty to figure it out how it works and i did figure it out but the Left$ and the number 1 inside the parenthesis are the ones that i cant understand. What does it do? i tried looking for the explanation in the tutorial and i cant seem to find any so pls any body wanna enlighten me about this code. even a small explanation will help TY
Feb 4 '07 #1
4 1522
Killer42
8,435 Expert 8TB
Left$(StringValue, Number) returns the first Number characters from StringValue. So for example, Left$("ABCDEFG", 3) would return "ABC".
Feb 4 '07 #2
iburyak
1,017 Expert 512MB
It is easy.

If your name for example David how to get your initial?
It is first letter of your name. In word David it is a first letter to the left so if you will take first left letter from the name it will be your initial.
$ sign is old punctuation means string result. I don't think it is used now but it is understood by VB.

[PHP]Left$(“David”, 1)

‘Returns
“D”[/PHP]

Function below is not working properly.
If you have (ByVal period As Boolean) it means you can return Middle initial with a period at the end if value is True and it should have an option to return just initial without a period if value is False. Your function returns always with a period no matter what parameter passed.

[PHP]Public Function MiddleInitial(ByVal period As Boolean) As String
MiddleInitial = Left$(middleNameValue, 1) & "."
End Function[/PHP]

To correct this it should be something like this:

[PHP]Public Function MiddleInitial(ByVal period As Boolean) As String
MiddleInitial = Left$(middleNameValue, 1) & IIF(period, ".",””)
End Function[/PHP]

In this case if period = True it will concatenate “.” to middle initial
if period = False it will concatenate with “” and will return middle initial only.

Good Luck.
Feb 4 '07 #3
iburyak
1,017 Expert 512MB
OOPS
Sorry Killer42. When I hit Submit I saw your respond.... . :)
Your answer is right to the point... :)
Feb 4 '07 #4
TY for fast reply i truly appriciate it ty
Feb 4 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Carolyn Gill | last post by:
I have already created an asp login/database for a learning/quiz section on a small site. There will be multiple quizzes through the site and what I need now would be help: tutorials or advice that...
3
by: ash | last post by:
Hey I am new, but I don't have time to intruduce myself yet. I am intro to C++ and this is a programme I have to write. all the direction are here, It will be very nice of someone to figure this...
17
by: Hazz | last post by:
In this sample code of ownerdraw drawmode, why does the '(ComboBox) sender' line of code need to be there in this event handler? Isn't cboFont passed via the managed heap, not the stack, into this...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
4
by: adam_kroger | last post by:
BRIEF EXPLANATION: I have 6 TextBoxes named LIS1, LIS2, LIS3, ... LIS6. I want to be able to reference them using a For/Next loop and either read ot write to them. In VBA I would use something...
1
by: vikjohn | last post by:
I have a new perl script sent to me which is a revision of the one I am currently running. The permissions are the same on each, the paths are correct but I am getting the infamous : The specified...
2
by: cephal0n | last post by:
Hi All! First of I apologize for my previews post needing help on union select and not providing so more explanation, but thank you very much for your opinion and sugestion. I have thought about my...
1
by: javabeginner123 | last post by:
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is...
24
by: kevin | last post by:
write a program in c.
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.