Try something like this:
Dim currentModuleCode As String = String.Empty
For i = 1 To dgvModStud.Rows.Count - 1
If dgvModStud.Rows(i).Cells(0).Value = currentModuleCode Then
dgvModStud.Rows(i).Cells(0).Value = String.Empty
else
currentModuleCode = dgvModStud.Rows(i).Cells(0).Value
End If
Next i
Then you do not need to worry about increment j. Also it means that when the module code changes you will get an entry for it, but the rest for that code should be blank.
This also means that if the list is not ordered then if a code re-occurs it will have a its code visible so it does not appear as if it is under the wrong one.