Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Friend Sub

What is a Friend sub and how is it used?,

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Friend Add Help
On myspace theres an action that works like this. To add a friend the URL is in this format:

HTML Code: FRIEND_ID_HERE&Mytoken=20050824183755

The friend ID is obviously the friend you would like to add. What I want is a
script that will collect IDs from a specific list. An example of a list is this(where the friends are listed):

HTML Code:

I want onclick command 1 add each link into list 1

Little Help For My Friend
I have a small Query of my friend.
He wants to check the size of a particular file ( say "aaa.sss").
If it is greater then X value then exit the program. If value less
then he wants to run an executable file ( say "aaa.exe")

He wants the Code in Turbo C
Unfortunately I donnt know TurboC language.

Can anyone Please mail me the code.


What Is A Friend?
I'm looking to understand inheritence well, but nowhere have I been explained the concept of "Friend."

MSDN Says:


The Friend keyword confers friend access on one or more declared programming elements. Friend elements are accessible from within the program that contains their declaration and from anywhere else in the same assembly.

The Friend keyword can be used in conjunction with the Protected keyword in the same declaration. This combination confers both friend and protected access on the declared elements, so they are accessible from the same assembly, from their own class, and from any derived classes.

As I understand it, whether we put "friend" in front of a Sub or Function or not, if that Sub or Function is public, then we can access it anyways.

I don't understand the concept and purpose of "Friend." Someone explain it to me. Without talking like MSDN. Talk like a normal person.


what is it mean when you declare something as Friend.

No Friend!!!
no with the above code u cannot create a dsn which maps to the network drive. since iam using the MS Access Database i should give absolute path of the database to the DSN at Runtime...
i need help on how to create and CONFIGURE the dsns with the mapped network drive.

thanks very much though....

i hope u will come up with a solution...

Please Help My Friend
when i just visit the and come to vbfourms it is automatically welcomming me. that's wonderful!

but the problem is my friend wants to register his name in the site
using my computer if i click register it is displaying that you are already registered and i am not getting a chance to create a new account for my friend . help me to do this.

Please Help My Friend
when i just visit the and come to vbfourms it is automatically welcomming me. that's wonderful!

but the problem is my friend wants to register his name in the site
using my computer if i click register it is displaying that you are already registered and i am not getting a chance to create a new account for my friend . help me to do this.

Please Help My Friend
As a long time reader of this group, I thought it would be ok to post

My friend Mike sent me this message today & it really bugged me. If
any of you can help him by making a Paypal donation to
Join Bytes! to help defray his legal costs, I'm sure the
Karma will find its way back to you in no time.


P.S. Please forward this to your friends.

>Subject: OMG I'm being sued[/color]

>Remember I told you my son, Michael got into a fight with the[/color]
neighbor's kid >while they were playing? Well, they are suing us for
harassment & mental >cruelty. They claim the fat little bastard can't
even go to school now & is >suffering from depression, all because my
kid gave him a black eye. Can you >freakin' believe it??????
>When I was 10, like these kids, I got into a scrap now & then, but it
>toughened me up & I learned to keep my mouth shut. We never sued[/color]
>I talked to my lawyer & he said, get ready for this, they HAVE A[/color]
CASE! WE >COULD LOSE! Un-freakin believable!!!!
>Nancy & I can't afford the damn lawyer bills, I don't know what we're[/color]
gonna >do...we could lose our house.
>Just thought you might be amazed at what our country has come to[/color]
these days. >GOD it pisses me off!

Any Friend Out There To Help Me
Can any one give me solution to convert .MHT to IMage file as this format is supported by all portals.Yahoo and few other don't allow viewing of mime format attachments.

Anticipating few useful replies

With this is attached a .MHT file which i want to send to different accounts such as hotmail,rediff,and yahoo out of which only rediff supports it.Any solution which can help me in converting mime to some acceptable format before sendinh it as an attachment


Friend Class Help
I am trying to write a class and to get it to compile I had to declaire one of the functions as a freind. However, I cannot seem to call this function from another, the error simply says I this method is not supported. Here is a sample of my code: Any ideas why I am getting this?

'This is cls_PulsePK

Public myPulse As Object
Public Type Pulse_Channel
Enabled As Boolean
title As String
Type As String
End Type

Public Sub Main()
Set myPulse = New clsPulse
End Sub

Public Function PK_GetNumMics() As Integer
Dim Channels() As Pulse_Channel
Channels = myPulse.GetBK_ConfigChannelNames
End Sub

'This is clsPulse

Private BK_ConfigChannelNames() As Pulse_Channel

Friend Function GetBK_ConfigChannelNames() As Pulse_Channel()
GetBK_ConfigChannelNames = BK_ConfigChannelNames
End Function

Friend Declaration
I am trying to understand the usage of the friend declaration. Does anybody have a good example of when to use this and when not to and what the reasons are for each alternative???

Help With Friend Properties
Hello Everybody ,

I need some help , I was creating a new ActiveX control, for using graphic interface in my applications, but I need a friend property in 2 objects of diferent class, the activex usercontrol and a form, i need to transfer an object from the usercontrol to the form.

If anybody knows a formula to do this please send me a message...


Me And My Friend Needs Work To Do.
Hey guys, me and my friend recently started on VB6 we have played alittle with msgboxes the most simple commands.

But now we are in a dilemma.

We dont know what to make, and that is maybe because we aint that good yet and we dont know the possibilities in VB6. At that reason, we wanted you guys to help us and give us ideas. And if our possibilities for building anything is too low. then give us some tips.

Regards Ditlev and Tobias.

Myspace Friend Bot
hi guys, i was wondering you you know anything of how these are made? i would like to know, i want to eventually get one out there.. if anyone has an up to date source for one i would appreciate it.. im using vb6 btw

Friend Function
What is the use of friend function in VB 6.0

Friend Functions In Vb??
Friend functions are functions defined outside a class (ie, not member functions), but which the class declares to be friends so that they can use the class's private members.

this is i guess the basic definition of a friend function but i have seen codes where friend keyword is used before functions in far as i know vb6 is an event driven language and not an OOB language.then how are friend functions implemented ??

Friend Property
Can someone give me an example of how to access one class
from another using the friend property?

Virtual Pet, Friend
Hi all!
Could u tell me please, any resource reffered to this subject.

Need Help With Saveing For My Friend
ok, my friend needs help with saveing data (text to be correct) and he has about 9 text box and wants to have it save to his own file extension (.sbk or .cry) when it saves (from form_unload) it well save the text and the information of which text was in which text box...can you help him out??

Friend Variable?
Is it possible to declare a variable as friend? I tried:

VB Code:
[color=red]friend something as integer[/color]

but I've got an error...

Friend Property & MTS
Can anyone explain to me the friend property and how it might relate to/clash with the Microsoft Transaction Server?

If you could point me towards any good online resources I'd also be very grateful.


Friend Function
What is a Friend Function?
Explain me with a small example.?

Helping A Friend

my friend has a vb question but i don't understand it i was wondering weather anyone else can help

here it is

when you link to an external file using OLE, for example excel. you have the
choice of using an icon to represent it.
How do you rename the label that the icon has?


Alternative To Friend In COM+
Hello Guys and Gals,
  My brain is mush and I'm trying to think of the best solution to a problem and I just can't think so please help if you can because I know I'm just missing something.

  I have an exsisting component with n classes in it.  I went through and made it pretty much stateless but the original authors have made things tricky for me.  Currently all the classes are public and they have some classes using friend functions for things that are allowed to be used internally.  But since you can't use Friend functions if you use GetObjectContext.CreateInstance() and I'm worried about using NEW until I do a bunch of testing to make sure it is properly the part of the current transaction.

  How do you handle a situation where you need a class internal to your component in the same transaction but you don't want that class exposed outside the component.  For it to have a MTSTransaction mode it has to be exposed outside.  My brain is mush....should I just be using NEW and have them set to private to get them enveloped in the components transaction?  

  Sorry for the probably easy question but ... Senility....its hitting me hard today.

One Of Ur Friend Desperately In Need Of Help......
Hi guys,

I am using vb with SQL...

In my form i am having autogenerating number.But starting number is in other table.

Number is like


if april 1 ,then Year should be changed automatically to 2003-2004.. I have done it.
11003550 -11 indicates the current month ------ Here is also no problem.

Here the number is 003550. This number is in one master table.

I am incrementing this number one by one for each record.

My code.....
Code:If BillDetailRs.RecordCount <= 0 Then
        If StartRefNoRs.RecordCount > 0 Then
            Temp = StartRefNoRs.Fields("currefno") + 1
            Temp = Format(Temp, "000000") ' Format the number to display like 003350
        End If
    End If
    'Get the starting number from Master table
    RefNoIncrementRs.Open "select max(cast(substring(referenceno,23,len(referenceno)-1) as int)) as MaxNo from t_billdetail", _
    con, adOpenKeyset, adLockOptimistic
        If RefNoIncrementRs.RecordCount > 0 Then
            If IsNull(RefNoIncrementRs.Fields(MaxNo)) = False Then
                Temp = Format(RefNoIncrementRs.Fields(MaxNo) + 1, "000000")
            End If
        End If
    Set RefNoIncrementRs = Nothing

It doesn't work if the starting number get changed....

ie) whenever we change the starting number in master table the incrementing number should be changed.
Say ,ialready i am having 3780 then if they change to 4000 in master table.
It should start from 4001

Help me pls....??

The above code is not working for this...

If i am not clear enough pls let me know , I will try to give details as much as i can...

Pls... Help me guys.

Edited by - sangeethra on 11/24/2003 4:19:39 AM

Friend Functions In VB
Hello all,

There is a query.

We want to retrict use of some class methods and properties to some particular classes.

We have tried using the "Friend" methods but they have a project scope that is they can be used by any class within the project.The restriction put is that they cannot be used by other clients (say new projects) but we want to have restrictions within the same project .

That is some class B and C should have access to class A methods and not every class can use class A methods.(Similar to friend functions functionality in C++).


Dear Friend
where can i get the VB/FAQ download?

Calling A Friend Procedure
According to what I read in the MSDN I should be able to call a friend procedure in a class from a procedure in a module.

Here's what I tried (it doesn't work)

'In a form
Private c As New Class1

Private Sub Command1_Click()
' Call the public sub in the module
End Sub

'In a module
Public Sub Call_Test()
' Call the friend function in the class module
End Sub

'In a class
Friend Sub Test()
MsgBox "Test"
End Sub
What am I not getting?

Friend Can't Run My VB Program Needs Some Files
My friend cant run my program he is mising osme files. were can i fine an install for him so he can get teh right files?

Declaring Friend Variables In VB
could you tell me how to declare friend scoped variables in Visual basic?

I tried with the following code in the Active X DLL Project

Friend abc as string

I got the Compiler Error....

I need one class member to act visible only in Active X Project but not visible for the Clients (COM Clients)

please help me.....

AIM Friend List Read
Well, Im wondering if someone would know of a way to read the friend list its a listbox i believe. All i need to do is like:

if instr(1, "aimfriendlistbox", "x39rox") then
playsound "c:lah"

I have the play sound n shizzle, I just need to know how to read the listbox. This might be API, i didnt know. Thanks guys

Run-time Error '97' While Using Friend.
I've got a Visual Basic 6.0 project that I inherited at my new job and I keep getting an issue when I run it on systems that don't have Visual Basic on them.

The project consists of multiple forms, one Module, and two class modules. One of the functions within one of the functions in a class modules is defined as a 'Friend' function and is causing problems when it is run on systems that don't have Visual Basic on them. I keep getting Run-time error '97' when I try to run it on systems other than the developement system.

I've checked Microsoft's online help to try to diagnose it but the conditions they say cause it are not the situation I have. I'm guessing there is something missing but I don't know what. Any help out there?


Creating A Friend Adder
This is for a site called

this is what i caught from firefox:

#request# POST
POST /index.php?pageid=mycrib.member.addfriend c=1&f=86&Submit=Add+to+Friends

so i'm using this code:

If lblStatus.Caption = "Logged in" Then
strHTML = RipperWrapper.Request("POST", " c=1&f=86&Submit=Add+to+Friends", "")
End If

and it just brings me to the front page...

Problems With My First Program, Friend Can't Run It!!!
Made my first project yesterday. Just one form, two buttons and two picture boxes. The buttons make a picture appear on the form. I debugged it and compiled it, clicked the exe and everything went great. I emailed it to a friend and when he opens it, it tells him that he needs to install .net something another. Why is it asking him this? Why is other programs working but not mine? It wasn't anything complicated. Am I gonna run into this with everyone that needs to install .net???

Friend Keyword And Practical Use
I created a property procedure in a class module.
The Get procedure is public.
The Let procedure is friend.
I compiled the project into a DLL and then added a reference to the new DLL to a brand new project.
I can still access the friend procedure from code in my new project.

Because of this I am a little confused as to how or what the friend declare does.

I thought, for instance, if I created a series of classes and compiled it into a DLL that the friend keyword would allow the different classes in the DLL to communicate the properties to one another without exposing those properties to a project that the compiled DLL was added to. Sorta like handing private messages back in forth in class without the teacher (the new project the DLL was added to) being able to see the notes. =)

Friend Variable Access
Is it possible for the following scenario?:

To have a variable declared in a form's declaration section:
CODEPrivate MyVariable As Integer

Kudos To Our Friend George
I've just noticed that our friend George (gmmastros), a regular contributor to our column, has topped 1000 stars in the SQL Programming forum.  George has helped me out of a couple of SQL Server admin jams; probably there would be plenty more if I spent more time in that world.

George, you're the "strongm" of the SQL forum, and I'd like to thank you for all the hard work you've put into tek-tips.  

Best regards,


My Version From My Head And My Friend's
I have put together a client/server chat program from what I could remember in my head. It has errors in it like not being able to connect and when inputting text to be sent, it comes out as numbers. I'm trying to determine how close I really am with all of this.

I would like to include the source that I had been going by that my friend had been using and this is the one I had tried to go by but I could never get it to work for me.

The first two will be mine and the rest his.

DataRepeater Control - Friend Of Foe?
Hello all,

I am trying to use the datarepeater control, with a custom active x control, but alas i am having major difficulties!

The custom control contains three text boxes and four check boxes, quite simple you might think. Having trawled the internet to find out how to get the parameters external so they can be bound i now face the following problem.

When i delete a record from the recordset the datarepeater is showing, it is removed from the list successfully, and appears to be deleted BUT if i close the program and reopen it the data magically reappears! Why Why Why is this happening???


I have successfully managed to make the datarepeater display new records (which it doesnt do by itself) using the following code,

   DatRep1.VisibleRecords(DatRep1.VisibleRows) = DatRep1.CurrentRecord

is there perhaps a similar line of code that makes sure the datarepeater DOES delete the record insetad of pretending to?


Trouble Calling Friend Sub From Another Form. VB6
Hey Guys,

This is realy puzzeling me as I have the same code running in another app without a glitch??

I have 2 forms, one pops up lets you add some info and update a recordset, this works well, after the update a Friend Sub on a command button on the other form is called to update that form with what was just done on the pop up form.

But im getting an error when the button is called on now??

Run-time error '97':
Can not call friend function on object which is not an instance of defining class.
If anyone could suggest whats going on here id be gratefull for any thoughts or support.

Regards as ever

Errors When I Send My Friend My Program
He gets the error : "Compile error, method or data member not found" and the porgram doesnt compile right, but on my computer it runs fine. I gave him all the files in the foler i saved all the files of my program to.

Get The Friend List From Yahoo Messanger
how can I get my Friend List from my running Yahoo Messenger?
hooking into the object or there is another method?
I can only intercept API messages by hook into the friend list window or I can get the content and properties of the friend list windows?

Friend Functions On ActiveX - For Gurus
dear all,

i've build two UserControls compiled into one single activex OCX that talk to each other via functions and properties declared as 'Friends'.

now, everything works fine in VB applications, VC, and delphi. that's a good start

however, i need to use these controls into an HTML page. basically i do not know how to connect those.

when i use:


and then via a vbscript i call these friends functions, like for instance:

SXcontrol.ActiveControl = SXtext

i get a can not call friend function on object which is not an instance of defining class.

basically it seems that these are seen as two separate objects instead of being part of the same OCX control.

...anyone has a clue on how to make this work? not sure if this is the right session of the forums, but do not know if this is a problem related to the vb code of the activex or to the HTML code i need to include them into a web page.

any help seriously welcomed, i'm completely lost and have to deliver this project.



Weird Problem (i Can Run Program But Friend Can't)
Does anyone know why the program is working for me, and my college computers but when my friend tests it on his home computer is displays the following error: Can't find project or library.

The screenshot is attached if you want to have a look.. I'm clueless, (I did add some custom references though that should automatically enable itself when program is run, plus it doesn't have anything to do with date)

Thanks for any advice !

Private, Public, Global, Friend
can any one explain the EXACT use of each of those?
thank you

Public, Private And Friend Property
Hello, my question is simple, I know what are public and private property, but what are friend property and what does it do. I mean, a public property is accesseble by everyone, private only in the same class module, and friend?

Using Friend Properties And Functions From A Usercontrol
I am not sure how to use Friend properties declared in a usercontrol from a class module. Here is what I am doing: I made a custom container control that has several options for a graphic style such as Office XP, Office 2003, Win XP, and Windows Classic. I made a class module for the colors of the different parts. I want to add friend properties to the control so that from the class module I can check if themes are supported, what the user's color scheme is, and if they want to use a custom color scheme.

I think I need to declare a reference to the control but this still doesn't look right. How do I point to the control?
' Color initialization from cEFColors.cls

Public Sub InitializeColors()
    Dim i As Long
    For i = idkEFRAMECOLORS.[_idkFrameColorFirst] To idkEFRAMECOLORS.[_idkFrameColorLast]
        m_eColors(i) = CLR_NONE
    Next i
' The following still doesn't seem right
    Dim c As ExplorerFrame
    m_eStyle = c.Style
    m_bUseCustomColors = c.UseCustomColors
End Sub

God Bless America

Friend Procedure Doesnt Show In Project
I am declaring a sub in a usercontrol as Friend (not Public or Private) I am led to believe that this will allow me to pass a UDT to and from it.

On my form that contains the usercontrol when I try to call this sub and its not there? any ideas. If its Public it can see it but then I cant pass a UDT then.

Ive been working on this for 3 days now and its just starting to bug me.

Any light would be much appreciated.


Hmm How Long Would It Take Me And A Friend To Create Out Own Scripting Language?
basicly something to simplify visual basics code so that the coding is more simple and then ofcourse mass produce it and make us filthy stinkin rich!!!! eaven richer than bill gates MUAHAHAHAHAHHAHA no seriously to and in a week when i start it will some of the peeps here be willing to help?

Copyright 2005-08, All rights reserved