Results 1 to 8 of 8
  1. #1

    Default How to display current user in the status bar using vb


    guys nana pud ko new post
    ask lang unta ko unsaon pag gamit sa status bar
    kanang human ug log in mo display ang name kung kinsa ang ni log in
    nag try ko sa label naka kuha ko
    pero sa tanang form ba butangan unta nako ug status bar.

    hope naay mo reply sa ako post

    salamat

  2. #2
    objStatusBar.Panels(lPanelIndex).Text = rs!UserName

    example:
    Code:
    dim rs as new adodb.recordset
    dim cn as new adodb.connection
    dim query, strCon as string
    
    Private sub form_load()
    strCon = "Your Connection String here"
    cn.open strCon
    End Sub
    
    Private Sub cmdLogin_Click()
    query="SELECT UName FROM tblUsers WHERE UName = '" & txtUName.text & "' AND Pass = '" & txtPass.text & "'"
    rs.open query, your preferred attributes here
    if rs.recordcount > 0 then ' kung naay username og password na nakita base sa giinput sa textboxes
         msgbox "Welcome " & txtUName.text & "", vbokonly+vbinformation, ""
         objStatusBar.Panels(1).Text = rs!UName
    end if 
    rs.close
    End Sub
    ^_^

  3. #3
    Quote Originally Posted by reyarita View Post
    guys nana pud ko new post
    ask lang unta ko unsaon pag gamit sa status bar
    kanang human ug log in mo display ang name kung kinsa ang ni log in
    nag try ko sa label naka kuha ko
    pero sa tanang form ba butangan unta nako ug status bar.

    hope naay mo reply sa ako post

    salamat
    Mo reply ko hap, but i won't give you codes; It's better nga ikaw ang mohimo ana. ; hata lang ko idea. Then try to research lang sa implementation. Coz if ma programmer ka puhon, knahanglan gyud ng research. lol.

    It doesn't matter if label or status text sa status bar e btang, depnde sa imo implementation.

    Are you familiar with inheritance?

    Imo buhaton is mag create kag Base Form; Now tanan nimo form is imong e inherit sa Base Form.

    Inside sa Base Form their should be implementation nga mo set sa Current User Caption/Text;

    Usually this will be set in Form Load; If this is set in the Form_Load event, make sure the method is not overridden, if e override man gani ang method please call always the base equivalent event.

    Now all you need is a storage for the Current User value, probably this would be of type String. I think its better if this variable/object should be static, para ang instance alive sa throughout application lifetime.

    All you have to do if after ni Login ang user successfuly is set the User value to the static variable/object.

    Back sa imong BaseForm assuming sa Form_Load sya mo set sa user caption, para pag set is use the value of that static variable para e set to imong User Text/Caption.


    Galibog ko ngano dli ko mohatag og code, nya d sad ko kbaw mo pasabot through typed messages. lol.

  4. #4
    sige update lang nya tka
    sa ako code

  5. #5
    try lang ni bro, basin kauyon ka sa style amo group

    1. We put a ToolStripProgressBar + ToolStripProgressLabel sa Main namo nga form (or sa karaan MDI)

    2. Declare public variable para sa username or unsa ba imo gusto ipa display

    3. ToolStripProgressLabel .text = username

    depende ra gyud na kung unsa imo preference bro, naa ra daghan controls sa .net

  6. #6
    mao sab ni ak ikapuno...

    kung gusto ka nga naa username sa statusbar sa imo tanang form. butangi ug statusbar object ang imo mga forms. then send the username into a glboal variable that can be use pag send sa value ngadto sa imo tanan statusbar inig load sa imo mga forms.

    e.g. >> statusbar1.panel(0).text = usernamevar

  7. #7
    Quote Originally Posted by elatagaw View Post
    mao sab ni ak ikapuno...

    kung gusto ka nga naa username sa statusbar sa imo tanang form. butangi ug statusbar object ang imo mga forms. then send the username into a glboal variable that can be use pag send sa value ngadto sa imo tanan statusbar inig load sa imo mga forms.

    e.g. >> statusbar1.panel(0).text = usernamevar
    it works, but the problem with this solution is you have to add the status bar in all your forms, if you are to add another form, again your gonna add another status bar to that form, it might be redundant.

    good solution would be again inheritance, all you need is to add that status bar on your base form, so all derived forms would have that user/status function/display.

  8. #8
    if you don't wan't to add status bar on all forms just make a mdi parent..

  9.    Advertisement

Similar Threads

 
  1. need help how to make album art in the cd
    By heavenknws in forum Windows Software
    Replies: 7
    Last Post: 03-24-2011, 01:25 AM
  2. How to maximize existing resources in the company to improve business?
    By CebuChamber in forum Business, Finance & Economics Discussions
    Replies: 0
    Last Post: 10-12-2009, 10:58 AM
  3. how to display "RUN command" in start menu?
    By jouho in forum Networking & Internet
    Replies: 17
    Last Post: 09-20-2007, 12:16 PM
  4. how to attach a file in the thread? (help!)
    By vbrhitchz in forum Music & Radio
    Replies: 4
    Last Post: 10-21-2006, 11:00 PM
  5. How to Get 2 Computers in the Same Online Game
    By erwincap in forum Networking & Internet
    Replies: 17
    Last Post: 11-21-2005, 05:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top