[VB.NET] The breakpoint will not currently be hit. No symbols have been loaded for this document.


Description
     i don't know the description about this problem.

How to

    to make breakpoint running again, i have some solution that you can try.

Solution 1
1. Backup All files inside BIN folder and copied to another folder.
2. Delete All files inside BIN folder.
3. Open VB.NET Solution (.sln) it will generate bin files automatically.
4. Running debug again.
5. if still occured go to solution 2.

Solution 2
1. Open VB.NET Solution (.sln).
2. Go to Build > Configuration Manager.
3. "On Active Solution Configuration" choose "Debug"
4. on the project context grid, look at column "configuration" make sure it's set "DEBUG" too, if it set release all debug mode will running as release (execute without any breakpoint).
5. and voila your breakpoint running again :)
6. if still occured go to solution 3.

Solution 3
1. google it.
* i am sorry i don't know :(

[VB.NET] DirectCast ToolStripMenuItem


Description
      i will explain about directcast to toolstripmenuitem, is it possible ?? until now and search google i don't find any method how to direct cast using "string" into toolstripmenuitem. but i found another method to control  toolstripmenuitem.

How To
the first thing you must know how depth your menu !! , ok let's see the explanation below
for example you have menustrip like this :

file                                        Edit            Help
   - user namagement :
           - change password
----------------------------
   - exit

the max depth above 3 , with 1 main menu and 2 sub menu :
main menu = File,Edit,Help
Submenu - depth 1 = User Management,Exit
Submenu - Depth 2 = Change Password

based on information above, we get max depth = 3 so just create 3 variable with type  toolstripmenuitem
Dim mainmenu As ToolStripMenuItem
Dim submenudepth1 As ToolStripMenuItem
Dim submenudepth2 As ToolStripMenuItem

after that you can parsing every item collection using foreach and "In" and don't forget add method ofType to find the item using specific type. why we use that because sparator different type with ToolStripMenuItem, here's the code

For Each mainmenu In frmMain.MenuStrip.Items.OfType(Of ToolStripMenuItem)()
    ' code
next

if you already understand the code above , you can learn easily the code below, here's the full code
Dim mainmenu As ToolStripMenuItem
Dim submenudepth1 As ToolStripMenuItem
Dim submenudepth2 As ToolStripMenuItem
 For Each mainmenu In frmMain.MenuStrip.Items.OfType(Of ToolStripMenuItem)()
        For Each submenudepth1 In mainmenu.DropDownItems.OfType(Of ToolStripMenuItem)()
               For Each submenudepth2 In submenudepth1.DropDownItems.OfType(Of ToolStripMenuItem)()
                       If submenudepth2.Name = "mnuchangepassword" Then
                                ' if specific menu is found using the name (condition)
                                'do you code
                                for example
                                submenudepth2.enabled = true
                       Else
                                ' just leave , the default i set is disabled
                       End If
                 Next
         Next
Next


here's the full example :
            Dim objDatabase As New database
            Dim connectionString, strsql As String
            Dim dataUser As DataTable
            Dim i As Integer

            Dim mainmenu As ToolStripMenuItem
            Dim submenudepth1 As ToolStripMenuItem
            Dim submenudepth2 As ToolStripMenuItem

            connectionString = "FILE NAME=" & My.Application.Info.DirectoryPath & "\SQLServer.udl"
            strsql = "select * from MS_USER_GROUP_DETAIL where GROUP_NAME = '" & CurrentRole & "'"
            dataUser = objDatabase.runningQuery(connectionString, strsql)

            ' ------------------------------------------
            ' MENU ASSIGN - Please edit your menu below

            If dataUser.Rows.Count > 0 Then
                i = 0  'index start from 0
                For Each mainmenu In frmMain.MenuStrip.Items.OfType(Of ToolStripMenuItem)()
                    For Each submenudepth1 In mainmenu.DropDownItems.OfType(Of ToolStripMenuItem)()
                        For Each submenudepth2 In submenudepth1.DropDownItems.OfType(Of ToolStripMenuItem)()
                            For Each fields As DataRow In dataUser.Rows
                                If i >= dataUser.Rows.Count Then
                                    'maka out of index
                                Else
                                    For Each itemName In dataUser.Rows
                                        'item(2) display record at column index no 2 (List of menu name)
                                        If itemName(2).ToString = submenudepth2.Name Then
                                            'if same name then enabled
                                            submenudepth2.Enabled = True
                                            i = i + 1
                                        Else
                                            ' just leave , the default is disabled
                                        End If
                                    Next
                                End If
                            Next
                        Next
                    Next
                Next
                i = 0 'reset index
            Else
            End If
        Catch err As Exception
            MsgBox(err.Message, vbCritical, "Application Crash")
        End Try

the code above very handy if you make user management with specific group and each group have many items that linking into menu.

[VB.NET] DataGridViewCheckBoxColumn explanation


Description
     if you need to add checkbox in your datagridview (VB.NET ), using DataGridViewCheckBoxColumn is the solution. but the example over internet is really pain, i don't understand why they use directcast only to get value ?? it's really pain !!. this tutorial , i will explain a simple method to get some value from checkbox either TRUE or FALSE but only for UNBIND not BIND to Database, with UNBIND you can manually modified the checkbox.

How  to

1. create your gridview , add new column and change the type to DataGridViewCheckBoxColum, and bring colum name "Grant"

2. to get data or set the value of checkbox do this :
datagridview1.Rows(x).Cells("cell_name_checkbox").Value = True
and voila your checkbox now checked , if you want to change into uncheck just use False

3. if you have some method after change state you can use CurrentCellDirtyStateChanged
    here's the example :
    Private Sub DGVItemList_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGVItemList.CurrentCellDirtyStateChanged
        If DGVItemList.Rows(x).Cells("Grant").Value = True Then
            MsgBox("cell check")
        Else
            MsgBox("cell uncheck")
        End If
    End Sub

note : "x" mark is index, ROW and COLUMN index start from 0.

[VB.NET] Could not find any resources appropriate for the specified culture or the neutral culture


Description
          "The error is: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "xXx" was correctly embedded or linked into assembly "zZz" at compile time, or that all the satellite assemblies required are loadable and fully signed."

that error above means the form cannot find the file that link resource. this error mostly occur when user copy the form to another project but forgot to copy the resource.


How To

to resolve this problem is simple just copy the resource !!

but if you didn't need the resource , but only need the form here's the step :

1. show all project files : Project > click Show All Files
2. look at the solution explorer you will see some file have mark like this (+).
3. find the problematic form, and click the mark (+) , it will expand and you will see another file with extention designer.vb and .resx. 
4. double click the .resx extention, it will apear a new view and find the problematic resource for example there is an image file, just remove it if you not need.
5. after remove just close the view and look again the solution explorer, now double click the extention file designer.vb at the same form.
6. you will see a may code that generate by system, press CTRL + F (find), type the name resource that you remove in the .resx file and click find next, after found the problematic resource , just comment it that code.
7. and voila your form will be running normally.

hope this article resolve your problem.

[VB.NET] Fungsi Terbilang


Description
     berikut adalah fungsi terbilang yang biasa berguna dalam keuangan.  

How To

1. write this code below in module :

Private Function terbilang_amount(ByVal Amount) As String
        Dim bilangan() As String = {"", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas"}
        If Amount < 12 Then
            Return " " & bilangan(Amount)
        ElseIf Amount < 20 Then
            Return terbilang_amount(Amount - 10) & " belas"
        ElseIf Amount < 100 Then
            Return (terbilang_amount(CInt((Amount \ 10))) & " puluh") + terbilang_amount(Amount Mod 10)
        ElseIf Amount < 200 Then
            Return " seratus" & terbilang_amount(Amount - 100)
        ElseIf Amount < 1000 Then
            Return (terbilang_amount(CInt((Amount \ 100))) & " ratus") + terbilang_amount(Amount Mod 100)
        ElseIf Amount < 2000 Then
            Return " seribu" & terbilang_amount(Amount - 1000)
        ElseIf Amount < 1000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000))) & " ribu") + terbilang_amount(Amount Mod 1000)
        ElseIf Amount < 1000000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000000))) & " juta") + terbilang_amount(Amount Mod 1000000)
        ElseIf Amount < 1000000000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000000000))) & " milyar") + terbilang_amount(Amount Mod 1000000000)
        ElseIf Amount < 1000000000000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000000000000))) & " trilyun") + terbilang_amount(Amount Mod 1000000000000)
        Else
            Return ""
        End If
    End Function


to use, just call the function !! for example : terbilang_amount(12300) & " rupiah"

will be returned : "dua belas ribu tiga ratus rupiah"

[VB.NET] Read - Write XML


Description
     this is simple example to read and write XML for VB.NET. if you have a better method please comment it. the best and simple way i will include in article. thanks

How To

Write XML - In Module :

Imports System.IO
Imports System.Text

Public Sub saveSettingXML()
        Dim savepath As String = My.Application.Info.DirectoryPath

        ' Create a string builder and write the user input from the textbox to it. 
        Dim XML As StringBuilder = New StringBuilder()
        XML.AppendLine("<?xml version=""1.0"" encoding=""UTF-8""?>")
        XML.AppendLine("<data>")
        XML.AppendLine("<person>" & "Mahendra" & "</person>" & vbCrLf)
        XML.AppendLine("<position>" & "IT Engineer" & "</position>" & vbCrLf)
        XML.AppendLine("</data>")

        ' Write the stream cotnents to a new file named "setting.xml" 
        Using outfile As New StreamWriter(savepath & "\setting.xml")
            outfile.Write(XML.ToString())
        End Using
    End Sub

and to use just call : saveSettingXML()

the XML text will be create like this : 
<?xml version="1.0" encoding="UTF-8" ?>
    - <data>
            <person>Mahendra</person>
            <position>IT Engineer</position>
      </data>



To Read XML above :

'always check existing file first !
 If System.IO.File.Exists(My.Application.Info.DirectoryPath & "\setting.xml") Then
            'if file xml exist read the setting
            Dim xml = XDocument.Load(My.Application.Info.DirectoryPath & "\setting.xml")
            frmInvoiceStandart.txtPersonName.Text = xml.<data>.<person>.Value
            frmInvoiceStandart.txtPersonPosition.Text = xml.<data>.<position>.Value
 Else
           'if not exist just create the setting or bla bla bla .....
End If

horayyyy :D