Jx_Man 987 Nearly a Senior Poster Featured Poster

monarchmk, Good Point.

Jx_Man 987 Nearly a Senior Poster Featured Poster

otomatis, if this thread already answered then please mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

if this thread already solved.
please mark as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

okay sir ParamArray is keyword and this is how to declare an array in vb6.0 sir?

ParramArray used to array with various parameter.

an example of array declare :
Dim NewArray() as Integer ' array with integer data type
Dim NewArray() as String ' array with string data type

u need to read this site about declare an array

actually if u have another question about vb then please create a new thread.
if u question already answered then please mark this thread as solved..

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi sir, Thank you for the reply, so this is used to disable the button minimize,maximize?am i correct sir...okay sir..Thank you again and more power to you...

u don't have to use api function to disable minimize and maximize,
there are properties in form to disable minimize and maximize button.

Jx_Man 987 Nearly a Senior Poster Featured Poster
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Double
        Dim i As Integer
        Dim sortarray(20) As Integer
        Randomize()
        For i = 1 To 20
            sortarray(i) = Rnd() * 100
        Next
        Array.Sort(sortarray)
        For i = sortarray.GetUpperBound(0) To 0 Step -1
            ListBox1.Items.Add(sortarray(i).ToString)
        Next i
    End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi sir can i ask what is the purpose of ubound?and what is ParamArray?.please help me sir. Can I ask favor can you put some comment of your code so that it can help me more and so that i can understand.Thank you in advance hoping for your positive response...

ParamArray lstview : declare lstview as array.
Sometimes we need a procedure that can accepts a variable number of arguments at various times during program( it means the procedure is sometimes called by passing one argument and at some later time same procedure can be called by passing two arguments etc.).
In this case we use the keyword ParamArray in definition header of the procedure that requires the variable number of arguments at various times.
We put this keyword in the parameter list that indicates that this procedure will receive a variable number of arguments.

UBound() : to determine the highest available subscript for the indicated dimension of an array. you can know how many index in lstview (an array). so you can know how many headers that u have to created.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Option Explicit
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

this is an API functions..
this function used to disable x button on the form, lock and unlock window, top most the form..
you can find that procedure on the listing program..

Jx_Man 987 Nearly a Senior Poster Featured Poster
Public x = 1 'This is whats wrong - it says "End of statement expected" when mouse over 
Public y = 1 'the "1"
Jx_Man 987 Nearly a Senior Poster Featured Poster

okay,,don't forget to give a feedback

Jx_Man 987 Nearly a Senior Poster Featured Poster

ok..so u want to use print function..
as i told u before that result of this function written directly on the form.
this function works fine to me..

an example :
This following code will print "Daniweb" 10 times in the form every time u click it.

Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 10
    Print "Daniweb"
Next i
End Sub

i upload a pic, so u can see if it not appear on your form. :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

first uncoment the recordsource part..
then add this procedure :

Public Sub AdoConn()
On Error Resume Next
Adodc4.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\ams\Attendancedb.mdb;Jet OLEDB:Database Password="
Adodc1.RecordSource = "SELECT * FROM LecturesAttended"
Adodc1.Refresh
End Sub

it seems like this :

Call AdoConn ' call procedure adoconn
Adodc4.RecordSource = "select  RollNo,Name, " + cmbMonth.Text + " from LecturesAttended where SubjectName='" + cmbSubject.Text + "'"
Adodc4.Refresh
Adodc4.Recordset.Fields(cmbMonth.Text) = txtLecturesattended.Text
Adodc4.Recordset.Update
MsgBox "Attendance added.", vbInformation, "Add Attendance"
Jx_Man 987 Nearly a Senior Poster Featured Poster

>>Where could I find a list of the most basic and useful commands with explanations, or even just like a dictionary of commands in VB?
MSDN and google

>>FullScreenButton.Name = "CloseFSButton" 'Do I need this line?
no you don't have

>>Now how do I make it Close full screen when that button has been clicked?
RenanLazarotto was give great example..

Jx_Man 987 Nearly a Senior Poster Featured Poster

you're welcome..
if this thread already done then please mark as solved :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi dorothy.v, you mark this thread solved before anyone answered it.
if you already found the answer of this thread then would you like to share the answer with us..
so if other members who have same problem with u can solve their problem too..
thanks :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

try to click row that u want to update on the datagrid then click add button

AndreRet commented: :) +7
Jx_Man 987 Nearly a Senior Poster Featured Poster

your information is not clear..and please use code tags

Jx_Man 987 Nearly a Senior Poster Featured Poster

this an example to load data into list view :

Public Conn As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Access_Connector()
    Set Conn = New ADODB.Connection
    Conn.Provider = "microsoft.jet.oledb.4.0"
    Conn.CursorLocation = adUseClient
    Conn.Open App.Path & "\Authors.mdb"
End Sub
Private Sub SetListView(LSV As ListView, ParamArray lstview())
    Dim i, width
    LSV.View = lvwReport
    width = LSV.width - 80
    With LSV.ColumnHeaders
        .Clear
        For i = 0 To UBound(lstview) - 1 Step 2
        .Add , , lstview(i), (lstview(i + 1) * width) / 100
        Next i
    End With
End Sub
Private Sub GetData(LSV As ListView)
Call SetListView(LSV, "Author Id", 25, "Author Name", 40, "Birth date", 35)
            
    'Set rs = New ADODB.Recordset
    rs.Open "SELECT * from Authors", Conn, adOpenDynamic, adLockBatchOptimistic
    
    LSV.ListItems.Clear
    
    While Not rs.EOF
        Set View = LSV.ListItems.Add
        View.Text = rs!Au_id
        View.SubItems(1) = rs!Author
        View.SubItems(2) = rs!YearBorn
        rs.MoveNext
    Wend
    rs.Close
    
End Sub

Private Sub Command1_Click()
GetData ListView1
End Sub

Private Sub Form_Load()
Access_Connector
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

great code :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

okay..
and if you don't have doubt again then please mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

why u want to use print function?
if u want to show a message u can use message box or other controls..

Jx_Man 987 Nearly a Senior Poster Featured Poster

you must create a button in toolbox and insert icon for it..
right click on toolbar-> properties
You can add button and insert icon there.

Jx_Man 987 Nearly a Senior Poster Featured Poster

you can see the result in the form..at top left corner..
the text is written directly into the form.

Jx_Man 987 Nearly a Senior Poster Featured Poster

great yousha..
thats what i mean..your input must be suitable with database criteria(data type)..
ok..then u can mark this thread as solved..:)

Jx_Man 987 Nearly a Senior Poster Featured Poster

your post is not clear..
what dbms are u using? access? mssql? mysql?
how far u doing this? show your effort first..

Jx_Man 987 Nearly a Senior Poster Featured Poster

Please use code tags

its hard to see them all..

i think your code is ok..maybe its about your inputs..
your inputs must be suitable with database criteria,,like date..

but i don't understand why u assignment value from textboxes to variables but u never using variables in select statment.

Jx_Man 987 Nearly a Senior Poster Featured Poster

>>Does it requires the Complete change in the code of the project or only a little changes
maybe yes, but it's not a big problem if you have working a lot with other DBMS..

see this thread :
One
Two
Three

see this site :
One
Two
Three
Four

Pdf Files

Jx_Man 987 Nearly a Senior Poster Featured Poster

not clear..more information friend...
User input current username in form1 and directed to form2..
In form2, Do you want to insert new data or you want to edit current user data?
if u want to edit current data in form2 then you should to use update query.

Jx_Man 987 Nearly a Senior Poster Featured Poster

your post is not clear. i can't understand what do you want to do.
1. you want to insert data in textbox to database?
2. what kind of database?access?
3. how far you doing this?

Jx_Man 987 Nearly a Senior Poster Featured Poster

First, You post on wrong section, this for vb4/5/6 not for vb.net

Dim formatOut1 As String = "{0,4} {16,23} {27,31}"
Dim formatOut2 As String = "{0,12} {16,23} {27,31}"

Your format string is out of index.
You have 3 items in your format string. The index of those 3 variables start at 0, for 3 items, the largest index you would have is 2.
see your format, the largest index is 27.

so it should be like this :

Dim formatOut1 As String = "{0,4} {1,23} {2,31}"
Dim formatOut2 As String = "{0,12} {1,23} {2,31}"

hope it helps.
marks as solved if it's done.

Jx_Man 987 Nearly a Senior Poster Featured Poster

so, what u want to do exactly?
you want to make a procedure?

>>make the program do something without the user doing anything

Private Sub First()
   Msgbox ("Hello World")
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Program CalculateDistance;
Uses WinCrt;
var
	x1,x2,y1,y2:integer;
	d:real;
begin
	Writeln;
	Write('Input A (X1): ');readln(x1);
	Write('Input B (X2): ');readln(x2);
	Write('Input A (Y1): ');readln(y1);
	Write('Input B (Y2): ');readln(y2);
	d:=sqrt(sqr(x2-x1)+sqr(y2-y1));
	Writeln;
	Writeln('Distance between A and B is: ',d:4:2);
end.
Sawamura commented: Quick respon +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this, it will return the position on the screen in pixels of the cursor :

Option Explicit
Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Function GetXCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetXCursorPos = pt.X
End Function

Public Function GetYCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetYCursorPos = pt.Y
End Function

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.Caption = "X Screen Position = " & GetXCursorPos
    Label2.Caption = "Y Screen Position =  " & GetYCursorPos
End Sub

Hope it helps.

Vega_Knight commented: Great Help +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

>>value of the first cell of the the first column of the any row index you click.
just put your code on the right event.

Private Sub dgStudentsHandled_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgStudentsHandled.CellClick
   Dim i As Integer
   i = dgStudentsHandled.CurrentRow.Index
   txtStudentNumber.Text = dgStudentsHandled.Item(0, i).Value
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

arezz09, can u share with us how you solved this..
it can help for other members who have the same question like you..

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're WElcome paulablanca, Dont Forget to mark this thread solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

arezz09 : codeorder give the complete guide :)

Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster
' this for create folder at c:\MyPicture\
If (Not System.IO.Directory.Exists("C:\MyPicture")) Then
    System.IO.Directory.CreateDirectory("C:\MyPicture")
End If

'this for open file in picture box
    Dim OpenFileDialog1 As New OpenFileDialog
    With OpenFileDialog1
        .CheckFileExists = True
        .ShowReadOnly = False
        .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
        .FilterIndex = 2

        If .ShowDialog = DialogResult.OK Then
            ' Load the specified file into a PictureBox control.
            PictureBox1.Image = Image.FromFile(.FileName)
        End If
    End With
	
' this for copying file
If System.IO.File.Exists(SourcePath) = True Then
    File.Copy(SourcePath, DestinationPath, True)
End If
Jx_Man 987 Nearly a Senior Poster Featured Poster

try this following codes :

' Shutdown
Private Const EWX_LogOff As Long = 0
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_REBOOT As Long = 2
Private Const EWX_FORCE As Long = 4
Private Const EWX_POWEROFF As Long = 8

Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type

Private Type LUID_AND_ATTRIBUTES
TheLuid As LUID
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type

Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long

Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, _
ByVal lpName As String, lpLuid As LUID) As Long

Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, _
NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long

Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)

Private Sub AdjustToken()

Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2

Dim hdlProcessHandle As Long
Dim hdlTokenHandle As Long
Dim tmpLuid As LUID
Dim tkp As TOKEN_PRIVILEGES
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long

SetLastError 0

hdlProcessHandle = GetCurrentProcess()

OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle

LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid

tkp.PrivilegeCount = 1
tkp.TheLuid = tmpLuid
tkp.Attributes = SE_PRIVILEGE_ENABLED

AdjustTokenPrivileges hdlTokenHandle, …
Estella commented: Nice codes ;) +4
dnk commented: Great Code Jx :) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

try this following code :

Program Decimal_Binary;
Uses WinCrt;
Var
	Dec,Deci: Integer;
	Bin: String;
	Ul:Char;
Begin
	Repeat
		Clrscr;
		Writeln('Decimal to Binary Convertion Program');
		Writeln('======================================');
		Writeln;
		Write('Input Decimal Number: ');Readln(Dec);
		Deci:=Dec;
		Bin:='';
		Repeat
			If(Dec Mod 2 = 0) Then
				Bin:='0'+Bin
			Else
				Bin:='1'+Bin;
			Dec:=Dec Div 2;
		Until Des=0;
		Writeln;
		Writeln(Deci,' Decimal = ',Bin,' Binary');
		Writeln;
		Write('Try Again? [Y/N]: ');Readln(Ul);
		Ul:=Upcase(Ul);
	Until (Ul<>'Y');
End.

hope it helps

Neji commented: good one +4
november_pooh commented: Thx..relly helps :) +3
Sawamura commented: helping.. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

no, that just an example code. i just show how to use string compare.
you need to modified it.

Dim i as Integer
Dim PassResult as String

PassResult = (a password taken from database, select result)
i = String.Compare(txtPassword.Text, PassResult, False) ' compare an inputed password with a password from database
If i = -1 Then
   MsgBox("Wrong Password")
ElseIf i = 0 Then
   ' same password, do anything as u wish 
End If
Jx_Man 987 Nearly a Senior Poster Featured Poster

1. u post in wrong section..this for vb4/5/6 not for vb.net
2. download mysql connector here, you already connected after installing connector. then u can write the program to read mysql data from vb.net
3. show us your effort friend. how far u doing this :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

in addition, you can use string compare function.

Dim i As Integer
i = String.Compare("dani", "DaNi", False)
If i = -1 Then
   MsgBox("Different")
ElseIf i = 0 Then
   MsgBox("Same")
End If
Jx_Man 987 Nearly a Senior Poster Featured Poster

>>how do i change the collation
read the link provide by adatapost

Jx_Man 987 Nearly a Senior Poster Featured Poster

yes you right. i didn't noticed it. :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

sorry.. i'm forgot to reply.

first, u dont have to use Shared function.

just make it as public : Public Function InsertNewRecord(ByVal myStoredProcedure As String) As Boolean then declare a new variable as your class instance..
ex : Dim Stuff as New DataAccess example when call at any event :

if Stuff.InsertNewRecord(ParameterHere) = True then
   msgbox "Data Added!"
end if

just it..

Jx_Man 987 Nearly a Senior Poster Featured Poster

binding data on combo box manualy then add items as u want.

Jx_Man 987 Nearly a Senior Poster Featured Poster

AndreRet : you seems right too..hmmm..i feel confused..his procedure name is "Add" but he tried to "update" an information..what update refers to? add a new record or edit a record? :confused:

Jx_Man 987 Nearly a Senior Poster Featured Poster

show your effort first friend :)