Jump to content
bDyds

Visual Basic 2010

Recommended Posts

Salut, am inceput sa lucrez in programul acesta si as vrea sa inteleg cum pot face ca atunci cand programul este deschis sa poata executa un proces. De exemplu, o instructiune de genul: daca hostnameul pcului este X, atunci sa arate ceva, altfel sa arate altceva. Imi trebuie pentru a face un program care atunci cand este deschis verifica daca fisierul exista si scrie intr-un fisier .txt hostname'ul pcului si dupa verifica daca hostname'ul pcului actual este egal cu hostname'ul pcului. As avea nevoie de suport pentru toata secventa daca se poate, daca nu, ma multumesc si cu niste sfaturi. Multumesc anticipat!

Link to comment
Share on other sites

Vezi ca ti-am scris un program acolo, ai si sursa si tot, vezi daca te ajuta cumva.

GirlShare - Download hostname.rar

Sau aici

Public Class Form1
    Private Sub BtnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCheck.Click        If My.Computer.Name = txtBox.Text Then            MsgBox("Hostname-ul este corect.")        Else            MsgBox("Hostname-ul este incorect.")        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim FILE_NAME As String = "C:\hostname.txt"
        If System.IO.File.Exists(FILE_NAME) = True Then            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)            objWriter.Write(My.Computer.Name)            objWriter.Close()            MsgBox("Hostname-ul a fost scris cu succes.")        Else            MsgBox("Fisierul hostname.txt nu exista.")        End If    End SubEnd Class
Link to comment
Share on other sites

Vezi ca ti-am scris un program acolo, ai si sursa si tot, vezi daca te ajuta cumva.

GirlShare - Download hostname.rar

Sau aici

Public Class Form1

Private Sub BtnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCheck.Click
If My.Computer.Name = txtBox.Text Then
MsgBox("Hostname-ul este corect.")
Else
MsgBox("Hostname-ul este incorect.")
End If

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FILE_NAME As String = "C:\hostname.txt"

If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write(My.Computer.Name)
objWriter.Close()
MsgBox("Hostname-ul a fost scris cu succes.")
Else
MsgBox("Fisierul hostname.txt nu exista.")
End If
End Sub
End Class

Multumesc frumos pentru cod, mi-am facut o idee ce trebuie sa fac. Totusi, as dori ca verificarea sa se faca fara sa trebuiasca sa apas pe un buton. Pot face asta cu un progress bar + timer?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...