Announcement

Announcement Module
Collapse
No announcement yet.

POST, Analise dan Share Code di sini - VBers

Page Title Module
Move Remove Collapse
This is a sticky topic.
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Re: POST, Analise dan Share Code di sini - VBers

    bantuin aku dong...

    kasih tau dong source codenya untuk mencari SN/ID dari PC yaitu:
    - Hardisk
    - NIC
    - MacAddress
    - Processor

    makasih ya..., lam kenal...

    Comment


    • #32
      Re: POST, Analise dan Share Code di sini - VBers

      @4903NK :
      akan lebih menyenangkan bila ada spesifikasi utk jenis OS-nya ?
      btw, welcome 4903NK
      i'll try to make one for what u askin.

      Regard, Positive+

      Comment


      • #33
        Re: POST, Analise dan Share Code di sini - VBers

        Variables Declaration

        Note : Just for noobs / beginners

        Download *.zip file archieve below

        Positive+,

        Comment


        • #34
          Re: POST, Analise dan Share Code di sini - VBers

          @4903NK :
          OK, this is it ( i've goto other computer first, this computer don't have VB )
          this what i made ( code tested on W2000 Prof / W32 bit)

          Code:
          Option Explicit
          
          '/ I give good code - Positive+
          Const NL = vbNewLine
          Dim temp As String
          Dim Obj As Object
          
          Function GetMac() As String
              temp = ""
              '// winmgmts:Win32_NetworkAdapterConfiguration=""0""" <-- 0 adl Index, gunakan looping bila perlu
              Set Obj = GetObject("winmgmts:Win32_NetworkAdapterConfiguration=""0""")
              temp = IIf(Not IsNull(Obj.MacAddress), _
                         "MAC Address Is : " & CStr(Obj.MacAddress), "Ngga dapet") & NL
              temp = temp & "Description Is : " & CStr(Trim(Obj.Description)) & NL
              temp = IIf(Not IsNull(Obj.IPAddress), _
                         temp & "IP is : " & CStr(Obj.IPAddress(0)), "") & NL
              '// Obj.IPAddress(0) <-- yup, kita ambil MAC pada index list 0 aja. kembali lagi it's up to you :D
              temp = IIf(Obj.DHCPEnabled = 1, temp & "DHCP is On", temp & "DHCP is Off")
              GetMac = temp '/ return
              Set Obj = Nothing '/ release memory usage
          End Function
          Function Hardisk() As String
          Dim oDrv As Object
               temp = ""
               Set Obj = GetObject("winmgmts:").InstancesOf("Win32_DiskDrive")
               
               For Each oDrv In Obj
                   temp = temp & "Hardisk Is : " & IIf(Not (oDrv.Caption) = "", oDrv.Caption & NL, "Ngga dapet")
               Next
               Hardisk = temp
               Set oDrv = Nothing '/ release memory usage
               Set Obj = Nothing '/ release memory usage
          End Function
          Function GetProcSerial() As String
          Dim oProc As Object
              temp = ""
              Set Obj = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
              '// back again, mengapa pake looping ? kemungkinan utk lebih dr 1 proc ttp ada
              For Each oProc In Obj
                  temp = temp & "Processor Serial is : " & IIf(Not IsNull(oProc.SerialNumber), CStr(oProc.SerialNumber), "Ngga dapet lagi") & NL
              Next
              GetProcSerial = temp
              Set oProc = Nothing '/ release memory usage
              Set Obj = Nothing '/ release memory usage
          End Function
          Private Sub Command1_Click()
              temp = GetMac() & NL & NL & GetProcSerial() & NL & Hardisk()
              MsgBox temp
          End Sub
          walaupun bs menggunakan API ( that's too long to code it ) jd saya hanya
          menggunakan apa yg bisa saya buat dlm waktu singkat saja.
          Tambahkan jg utk cek OSVersion user km. Code di atas hanya mengambil semua informasi dr service windows yg sedang berjalan. ( Thought, that's da easy way and short to get what we want it ).
          semoga berguna, have fun with it

          ( Ma'af saya br bs balas skrg. Ma internet access s**k right now )
          Positive+,
          Last edited by positive+; 25-12-2005, 18:49.

          Comment


          • #35
            Re: POST, Analise dan Share Code di sini - VBers

            To all :

            Tolong, bila kamu menggunakan code2 yg saya berikan :

            Bila terdapat bugs / kamu menemukan beberapa kesalahan pada code yg saya berikan. Post di sini mengenai bugs description-nya.

            Bila code yg berhubungan dengan System, sertakan juga untuk jenis OS yg
            kamu gunakan. ( seperti System API code, Services, etc )

            Bila code yg berhubungan dengan database, sertakan juga nama database, OS ( ServicePack ,etc ) dan bugs description-nya.

            Selebihnya saya akan mencantumkan pada OS mana code has been tested.
            saya akan sangat ber-terima kasih sekali untuk itu

            Best Regard to All VBers, Positive+
            Last edited by positive+; 28-12-2005, 21:18.

            Comment


            • #36
              Re: POST, Analise dan Share Code di sini - VBers

              Counting Words In a File

              I have been questioned by other forum member, about How to counting word in a file, here is ma answered .. thought, might be u need one about that

              Code:
              '// ========================//========================
              '// counting words in file - Positive+ Samples
              '// ========================//========================
              Private Sub Command1_Click()
              Dim temp As String, marr() As String
              Dim i As Long
                  ' default value string is vbnullstring
                  temp = ""
                  ' open file with binaries methode - much faster than Ascii methode
                  ' you can change da file path to yours - course
                  Open "C:\data.txt" For Binary As #1
                       temp = Space(Fix(LOF(1)))
                       Get #1, , temp
                  Close #1
                  ' now, replace all string that we define not as a word to space or vbnullstring
                  temp = Replace(Replace(Replace(Replace(temp, vbNewLine, " "), ",", ""), ".", ""), "/", " ")
                  ' put all word in dynamic array var, split by space
                  marr() = Split(temp, " "): temp = ""
                  ' now, loop to get it listed
                  For i = LBound(marr()) To UBound(marr())
                      temp = temp & marr(i) & vbNewLine
                  Next
                  ' show msg list of word
                  MsgBox temp, 0, "List of words"
                  ' counting word result
                  MsgBox UBound(marr()) + 1, 0, "Word Count"
                  ' erase array as empty
                  Erase marr()
              End Sub
              '// ========================//========================
                  'have fun coding ::.
              '// ========================//========================

              Comment


              • #37
                Re: POST, Analise dan Share Code di sini - VBers

                Short Explanation For VB Noobs knowledge - Positive+
                ================================================== ==
                Out Of Memory bugs of VB ::.
                ================================================== ==
                Yeah, ini salah satu bug dari VB yg tidak akan pernah diperbaiki oleh microsoft
                " Out Of Memory ". hingga menjadi salah satu dilema bagi programmer VB
                hal ini bukan disebabkan oleh karena memory computer kita yg terpakai habis oleh VB
                hingga ngga da space lagi utk action lainnya ( nob, that's totally wrong )
                " Out Of Memory " ini disebabkan karena VB membuat buffer memory sendiri untuk
                semua kebutuhannya, mulai dari object, penempatan variable ,etc.
                So, what will happen if we run out of that space ? akan muncul pesan yg sangat mengesalkan " out of memory " dan akan terlihat seperti semua code2 kita jadi ngga berguna, object2 yg terlihat freeze, etc. ( Restart computer will fix it )
                Dan lebih parahnya lagi, this memory space digunakan oleh setiap applikasi VB ( IDE )
                so, bila kita akan membuka Instance baru dari IDE VB, all clipboard usage, etc will be clean up with no compromise first.
                jadi, apa yg bisa kita lakukan utk itu ... Hhhh, live with it ... but, dimana ada kekurangan
                disitu juga pasti ada kelebihan keep ur smile
                ================================================== ==
                What is Option Explicit ::.
                ================================================== ==
                Option Explicit -- Singkatnya variables must be declared / setiap variable yg akan digunakan harus dideklarasikan terlebih dahulu.

                Apa keuntungan dari penggunaan ini ? Program kamu akan lebih cepat, aman dan bersih
                yup, banyak keuntungan hanya dari sebaris kata " Option Explicit "
                dengan menggunakan Option Explicit, VB akan melakukan swap terlebih dahulu dari semua variable yg digunakan, menyesuaikan dan menyiapkan variable utk data yg akan diterima, space dari memory yg akan digunakan oleh setiap type variable, etc.
                Contoh dari deklarasi variable :
                '// Yup, menggunakan Option explicit - but, declarasi dari variable tidak ditentukan typenya ??
                Option Explicit
                Sub Test()
                '// Pembuatan variable spt ini, VB akan secara automatic menempatkan-nya sbg Variant
                '// dimana type dr variable akan ditentukan dengan data / value yg dipegang oleh var itu nantinya
                Dim A
                A = "Positive+" '// Yup, disini VB akan menetapkan bahwa type dr var ini adl String sesuai dgn data yg dipegang oleh var tsb - declarasi spt ini cukup lambat dan kotor
                End Sub
                Sub Test()
                '* Hhh, deklarasi variable spt ini yg bener2 tidak terkontrol dan kotor - no Option Explicit
                '* Not recommended to use like this
                A = "Positive+"
                End Sub
                '// Yup, this is the correct variable declaration and the correct way to begin code
                Option Explicit '// always use this ... ALWAYS !!!
                Sub Test()
                Dim A As String
                A = "Positive+"
                End Sub
                OK then, i just have a short time to access da internet and ma seat at da office has been waiting 4 me. Semoga penjelasan singkat utk para beginner VB ini dapat menjadi pegangan dan pandangan dlm melakukan programming with VB.
                I'll write more later Keep da spirit alive and burn that keyboard on
                ( If there's a question or some to discuss .. add here )

                Fight till the end of ur live, Positive+

                Comment


                • #38
                  Re: POST, Analise dan Share Code di sini - VBers

                  Yth,
                  Rekan-rekan milis

                  saya sedang ada masalah, mohon pencerahannya!
                  begini saya sedang membuat sebuah database yang didalamnya ada 3 tabel (2 tabel entitas, dan 1 tabel transaksi)
                  tabel 1 mempunyai atribut : -id1 (key)
                  jns_mat
                  tabel 2 mempunyai atribut : -id2 (key)
                  Supplier
                  tabel 3 mempunyai atribut : -id3 (key)
                  qty
                  permasalahannya:

                  - bagaimana ER-nya apabila key pada tabel 3 adalah gabungan dari key tabel 1 dan 2,
                  contoh: key tabel 1 (id1) : MA
                  key tabel 2 (id2) : 02
                  key tabel 3 (id3) : id1+ id2 = MA02
                  - bagaimana codenya pada program nanti apabila kita akan melakukan query maka kita cukup memasukkan id3 saja dan program mengerti bahwa yg dimaksud adalah barang dengan jenis tertentu yg diambil dari tabel 1 dan dari suplier tertentu yg ada di tabel 2.
                  -dan jga coding yg efektif untuk melakukan proses edit, update n erasenya bagaimana?

                  atas bantuannya saya ucapkan terimakasih.

                  Comment


                  • #39
                    Re: POST, Analise dan Share Code di sini - VBers

                    @Dewaputra, what database ???
                    ================
                    1. tabel 1 mempunyai atribut : -id1 (key) -> MA
                    [ jns_mat ]
                    2. tabel 2 mempunyai atribut : -id2 (key) -> 02
                    [ Supplier ]
                    3. tabel 3 mempunyai atribut : -id3 (key) -> MA02
                    [ qty ]
                    =================
                    ER [ jns_mat ] <> [ qty ] and [ Supplier ] <> [ qty ]
                    to linked ( Relation ) between one table to other - must have same data type and values instead ! ( consider to re-construct )
                    [ if not with relationship chase it by records ]

                    - bagaimana codenya pada program nanti apabila kita akan melakukan query maka kita cukup memasukkan id3 saja
                    use MID() or else instead

                    -dan jga coding yg efektif untuk melakukan proses edit, update n erasenya bagaimana?
                    Code:
                    Option Explicit
                    
                    '** put on modules **
                    
                    Enum ma_action
                         Added = 0
                         Updated = 1
                         Deleted = 2
                    End Enum
                    
                    Private Type brg '** bring this anywhere u want < add, update, del >
                         id     As String
                         nm_brg As String
                         etc    As String
                    End With
                    
                    Private Type supplier '** bring this anywhere u want < add, update, del >
                         id     As String
                         nm     As String
                         phone  As String
                         etced  As String
                    End With
                    
                    Public ma_stuff As brg
                    ' or Public ma_stuff() As brg <- dynamic array -> browse -> searching
                    ' ma_stuff < values > put on object u desired
                    Public ma_supp As supplier
                    ' or Public ma_supp() As supplier <- dynamic array -> browse -> searching
                    ' ma_supp < values > put on object u desired
                    
                    Sub do_actions(iAct As ma_action, Tbl As String, Optional sId As String = "")
                        'SQL sample = "select * from [" & tbl & "] where --> condition --> use [ sId ] params
                        'check iAct for which Tbl instead
                        'do ur actions here
                        Exit Sub
                    End Sub
                    
                    '** positive+ ** good day and happy coding
                    [ note ]
                    For searching [ use array to make ur app more faster % LIKE % too heavy ]
                    Selecting [ use array too  ( * ) this asterix heavy enought 
                    
                    efective or not ... that's relative
                    hope that help, Positive+
                    Last edited by positive+; 17-01-2006, 22:18.

                    Comment


                    • #40
                      Re: POST, Analise dan Share Code di sini - VBers

                      4 positive+

                      databasenya adalah database material, dalam db itu ada 3 tabel:

                      tabel1 mempunyai 2 atribut :
                      - id1 sebagai key
                      - jns_mat

                      tabel2 mempunyai 2 atribut :
                      - id2 sebagai key
                      - suplier

                      tabel3 mempunyai 2 atribut :
                      - id3 sebagai key
                      - Qty

                      nah saya mau membuat id3 adalah gabungan dari id1 n id2 jadi satu material dapat ditentukan jenis dan supliernya berdasarkan id3 saja contoh:

                      pada tabel 1 :
                      id1 = MA
                      jns_mat = silicon ruber

                      pada tabel 2 :
                      id2 = 02
                      suplier = tanashin

                      pada tabel 3 :
                      id3 = MA02 (gabungan id1 dan id2)
                      qty = 1000 kg

                      nah pada saat di program, user cukup menginput id3 saja, maka program akan langsung menampilkan jns_mat, suplier, n qty.

                      klo soal coding mungkin apa yg anda buat sudah cukup bagus, tetapi yg menjadi masalah adalah bagaimana menghubungkan id1, id2 dan id3 secara ERD-nya

                      bagaimana apakah anda dapat memberikan pencerahan dari masalah ini?

                      Comment


                      • #41
                        Re: POST, Analise dan Share Code di sini - VBers

                        First, mean what database is --> which DBMS
                        so, ur database name is Material DB, ok then

                        from what u explain here, i don't see any relation between table 3 to 1 and 2
                        this statement of mine ( i think u already know it )
                        to linked ( Relation ) between one table to other - must have same data type and values instead ! ( consider to re-construct )
                        so, u got ur own reason to make ur database design to look like that, i can't argue with that, in fact i know nothin to ur problems

                        but, if u want it :
                        ==========================
                        Make [table 3] as detail table
                        contain : id3,id1,id2, [child field ] . . .
                        now, from that IDs, [ id2 linked to Table 2 ] and [ id1 linked to Table 1 ]
                        so, [Table 1] and [Table 2] is Master Tables
                        ==========================

                        from ur design, u can make [Table 3 ] not relation to any tables in ur DB.
                        so, da only way u can do is Hard Coding, check one by one, split da [Id3] values, to sync values from other tables [ Table 1 ] and [ Table 2 ]

                        [ id1 = MA ] - [ id2 = 02 ] - [ id3 = MA02 (gabungan id1 dan id2) ]

                        u see, how about if [ id1 = MA ... MZ or AA ... AZ , etc ] If [ id2 = 99 ] then u lost ur path there - [ id3 = MZ99 ]

                        you'll make new problems in da end. ( but, i know nothin about ur problems .. so, consider it obey ur self )

                        ( truely i hate relations - but, if i want to chase ma database i should to do data analizing first, about what will i get, then design da tables )

                        =============================================
                        about db code ::.
                        =============================================
                        If this is ADODB Classes and their trees Classes
                        =============================================
                        ADODB <--> Engine Drivers <--> Databases
                        |
                        < connection link classes >
                        (0) Connection Classes <-- Recordset Classes (1)

                        < subtrees of Recordset Classes >

                        (1) Recordset <--(2)Class Tables <--(3)Class Fields <---(4)Class Data Type, etc --

                        =============================================
                        Then u can choose which Classes are quicker to use for certain sql statement of yours, etc

                        I'll wait ur comments, later

                        Regard, Positive+

                        Comment


                        • #42
                          Re: POST, Analise dan Share Code di sini - VBers

                          positive+

                          I see u'r point, by the way I'm using SQL Server 7 for my DBMS

                          but I still have 1 question, cause I don't quite understand with what you mean I loose my path?

                          u see, how about if [ id1 = MA ... MZ or AA ... AZ , etc ] If [ id2 = 99 ] then u lost ur path there - [ id3 = MZ99 ]

                          Comment


                          • #43
                            Re: POST, Analise dan Share Code di sini - VBers

                            @Dewaputras,
                            da meaning is from da records side
                            if da record in [ id1 = MA ] ma opinion da increment values is [ MA..MB..MC..till MZ ] when da record reach [ MZ ] what will u do ? do you have to restart from [ MA ] again or what ? so do to [ id2 = 02 ] ma opinion same like [ id1 ] records, da increment things if reaches [ id2 = 99 ].
                            da indexes like we all know must be unique can't be indentical, when that problems comes to u, what will u do ?? course, that will affect your [ Table 3 ] records too, CMIIW that's what i mean you'll lost ur path ... from da records side.

                            but, if u think da records will not reach that values or u have other reason, i still stand from ma statement above - i know nothin bout ur problems there.
                            so, considerations is belongs to u now.

                            da coding things, you'll know which coding faster or not if u understand more about database contexts u using ( ADO, DAO ,etc) try to make ur own classes that act like that, then you'll know da secret of them. when u discovered all those things, there's no way coding can beat u up coz u have some point that break their point.

                            Open to me, than i'll open to you more
                            Best Regard, Positive+

                            Comment


                            • #44
                              Re: POST, Analise dan Share Code di sini - VBers

                              Story of ::.

                              When i got 1 thing ... just 1 thing, then i'll thinkin for 1 thing only
                              but, when 1 becomes 2 or greater than 1, then i should to think for billion things.
                              how can i think from billion things to be 1 thing
                              then from 1 thing, i can get much possibilities
                              where all of those possibilities refer to other linked possibilities
                              but in da end, i should to make all of those possibilities to 1 canonic thing.
                              When i got 1 canonic thing, then i try to make from horizontal building to vertical building, yeah ... that's must be hight !

                              not a bunch barricade of childrens without parent.
                              where all childrens must know their parents, so do da parents.
                              When da parent meet each other to other parent in a different home, da parents will tell their children each other, so da children no need to re-introductions.

                              When da parents like to make gathering, so da parents made one special place where they can meet each other. From that place parents can make a call to their children at home, at anytime they want...parents, they like to do that, talk about their childrens and random things

                              Childrens, they have a different attitudes and characters...childrens

                              Continued ....

                              Comment


                              • #45
                                Re: POST, Analise dan Share Code di sini - VBers

                                Database Function [ Searching ]

                                Now, build this function as fit as u need


                                Code:
                                'Positive+ - [ Databases ] Sub Modules
                                
                                Public Function search_dyna(iKey As String, iTbl As String, _
                                                            sCompare As String) As Boolean
                                '**********************************************************
                                'Params Descriptions :
                                '**********************************************************
                                'iKey     = Field Name in table _
                                'iTbl      = Table Name in DB _
                                'sCompare = Values to match at curr Key [ iKey ] and curr Table [ iTbl ]
                                '**********************************************************
                                Dim TempT As String
                                    TempT = "select [" & iKey & "] from [" & iTbl & "] where [" & iKey & "]='" & sCompare & "';"
                                    'Return True if [ Not EOF ] and False if [ EOF ]
                                    Exit Function
                                End Function
                                
                                da function will search at any tables, any field u want and any comparison values u need

                                u see da comparison values is a [ String ] how about da [ iKey ] values not a [ String ]
                                see da main structure and if u made better, u can post here.

                                Comment

                                Working...
                                X