Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

VB.NET Programming Corner!

kaya mo ba i convert sa HEX man lang yung string?

wala ba sa setting ng reader mo yan? baka naman pwede bsahin as HEX, kasi yun ginamit kong ACR120 wala naman ganyan, binabasa ko as hex so walang problem sa characters


baka sayo chinese ang settings

kaya ko po sya iconvert sa HEX..salamat po sa suggestion :salute:

wala pong makikitang setting yung reader eh..eto kasi nabili lang namin sa eGizmo, yung Arduino RS232 rfid reader... reader, manual at card yung binigay lang samin.. :)

try ko po yung sinabi niyo..salamat master! :praise:
 
i made that code for cyrilkun in 20mins, i dont have that much time. may possible flaws pa sa code. cyrilkuns, situation is way different. if you could back read, you can see that he has some dll missing in his system, thus, this was the approach he made.

it was cyrilkuns idea to make it look like that. im just giving him what he needs. if he opt to reconstruct his program, then i would gladly help.

*there's so many ways to cook a food*
 
ganito gwin mo..

Private Sub LoanApp_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim x As Integer
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & My.Application.Info.DirectoryPath.ToString() & "\Database\Coop.mdb;"
sql = "SELECT EmployeeIDNumber, LastName, FirstName, MiddleName FROM Members"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Members")
max = ds.Tables("Members").Rows.Count
For x = 0 To max - 1
cboEmployeeIDNumber.Items.Add(ds.Tables("Members") .Rows(x).Item(0))
Next
con.Close()
MaxRows = ds.Tables("Members").Rows.Count
inc = -1
End Sub


Private Sub cboEmployeeIDNumber_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboEmployeeIDNumber.SelectedIndexChanged
GetData (cboEmployeeIDNumber.Text)
End Sub

Private Function GetData(IDNumber as String)
Dim x As Integer
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & My.Application.Info.DirectoryPath.ToString() & "\Database\Coop.mdb;"
sql = "SELECT EmployeeIDNumber, LastName, FirstName, MiddleName FROM Members WHERE EmployeeIDNumber = "' & IDNumber & "'"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Members")
max = ds.Tables("Members").Rows.Count
Me.txtLastName.Text = ds.Tables("Members").Rows(0).Item("LastName")
Me.txtFirstName.Text = ds.Tables("Members").Rows(0).Item("FirstName")
Me.txtMiddleName.Text = ds.Tables("Members").Rows(0).Item("MiddleName")
con.Close()
MaxRows = ds.Tables("Members").Rows.Count
inc = -1
End Function


yan try mo.. nka auz n yan.. hnd q n natest wla n q tyme eh.. w n bahala jan.

dun nga pla s id.. nka string un s query.. make sure n match ung datatype s codes at DB mo.


napagana ko na siya sir.. ganito ginawa ko:
binago ko lang yung "Rows(0)", ginawa kong "Rows(cboEmployeeIDNumber.SelectedIndex)" :thumbsup:

salamat po sir, pati kay sir erick.. :praise:
 
i made that code for cyrilkun in 20mins, i dont have that much time. may possible flaws pa sa code. cyrilkuns, situation is way different. if you could back read, you can see that he has some dll missing in his system, thus, this was the approach he made.

it was cyrilkuns idea to make it look like that. im just giving him what he needs. if he opt to reconstruct his program, then i would gladly help.

*there's so many ways to cook a food*

nice, sana matapos na ni cyrilkun yung project nya.
 
@cyrilkun - inabot ako ng oras nito, this is another option, if you need explanation pm mo nalang ako, online ako until 1am.

6 buttons
1 panel
3 labels
2 textbox

btnStart, btnRetry, btnCorrect, btnWrong1, btnWrong2, btnWrong3
panel1
lblQuestion, lblLife, lblCorrect
txtLives, txtCorrect

and the code

Code:
Public Class frmMain

    Private Questions As New List(Of List(Of String))
    Private RandomIndex As List(Of Integer)
    Private RunningIndex As Integer = 0
    Private totalCorrect As Integer
    Private totalLife As Integer = 3

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        GenerateQuestion(RandomIndex(RunningIndex))
        shuffle()
        btnStart.Enabled = False
        btnRetry.Enabled = True
    End Sub

    Private Sub shuffle()
        Dim nListOfLocation As New List(Of Point)

        With nListOfLocation
            .Add(btnCorrect.Location)
            .Add(btnWrong1.Location)
            .Add(btnWrong2.Location)
            .Add(btnWrong3.Location)
        End With

        Dim ShuffledList As List(Of Integer) = GenerateUnique(4, 1, 4)

        btnCorrect.Location = nListOfLocation(ShuffledList(0) - 1)
        btnWrong1.Location = nListOfLocation(ShuffledList(1) - 1)
        btnWrong2.Location = nListOfLocation(ShuffledList(2) - 1)
        btnWrong3.Location = nListOfLocation(ShuffledList(3) - 1)
    End Sub

    Private Sub GenerateQuestion(ByVal nRandomIndex As Integer)
        Dim myQuestions As List(Of String) = Questions(nRandomIndex - 1)

        lblQuestion.Text = myQuestions(0)
        btnCorrect.Text = myQuestions(1)
        btnWrong1.Text = myQuestions(2)
        btnWrong2.Text = myQuestions(3)
        btnWrong3.Text = myQuestions(4)

        RunningIndex += 1
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddQuestionChoice("Question1", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question2", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question3", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question4", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question5", "Correct", "Wrong1", "Wrong2", "Wrong3")

        retry()
        btnRetry.Enabled = False
    End Sub

    Private Sub AddQuestionChoice(ByVal nQuestion As String, ByVal nCorrect As String, ByVal nWrong1 As String, ByVal nWrong2 As String, ByVal nWrong3 As String)
        Dim QuestionChoice As New List(Of String)

        With QuestionChoice
            .Add(nQuestion)
            .Add(nCorrect)
            .Add(nWrong1)
            .Add(nWrong2)
            .Add(nWrong3)
        End With

        Questions.Add(QuestionChoice)
    End Sub

    Public Function GenerateUnique(ByVal LoopCount As Integer, ByVal rMin As Integer, ByVal rMax As Integer) As List(Of Integer)
        Dim holder As New HashSet(Of Integer)
        Dim rand As New Random

        Do
            holder.Add(rand.Next(rMin, rMax + 1))
        Loop Until holder.Count = LoopCount

        Return holder.ToList
    End Function

    Private Sub btnRetry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetry.Click
        retry()
    End Sub

    Private Sub retry()
        Panel1.Enabled = True
        btnStart.Enabled = True
        btnRetry.Enabled = False
        lblQuestion.Text = Nothing

        RunningIndex = 0
        totalCorrect = 0
        totalLife = 3

        txtCorrect.Text = totalCorrect
        txtLives.Text = totalLife

        RandomIndex = GenerateUnique(Questions.Count, 1, Questions.Count)
    End Sub

    Private Sub btnCorrect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCorrect.Click
        If RunningIndex < Questions.Count Then
            GenerateQuestion(RandomIndex(RunningIndex))
            shuffle()
            totalCorrect += 1
            txtCorrect.Text = totalCorrect
        ElseIf RunningIndex = Questions.Count Then
            totalCorrect += 1
            txtCorrect.Text = totalCorrect

            RunningIndex += 1 ' append running index ' this is the last question
        End If
    End Sub

    Private Sub btnWrong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrong1.Click, btnWrong2.Click, btnWrong3.Click
        If RunningIndex < Questions.Count Then
            If totalLife <= 1 Then
                totalLife = totalLife - 1
                Panel1.Enabled = False
                MsgBox("game over")
            Else
                GenerateQuestion(RandomIndex(RunningIndex))
                shuffle()
                totalLife = totalLife - 1
            End If
        ElseIf RunningIndex = Questions.Count Then
            totalLife = totalLife - 1
            RunningIndex += 1  ' append running index ' this is the last question
        End If

        txtLives.Text = totalLife
    End Sub
End Class

palitan mo nalang yung form main load, di ko na ni arrange, kakain muna ako. lol. gutom na. if you would like to have an easy, medium, hard, gawa ka nalang ng new list, clear mo yung Questions tapos AddQuestionChoice nalang.

Random Question with Random Answers (ipag papalit nya ang location ng choices, kahit saan mo ilagay yung mga buttons), yung AddQuestionChoice lang kelangan mo galawin.
 
@cyrilkun - inabot ako ng oras nito, this is another option, if you need explanation pm mo nalang ako, online ako until 1am.

6 buttons
1 panel
3 labels
2 textbox

btnStart, btnRetry, btnCorrect, btnWrong1, btnWrong2, btnWrong3
panel1
lblQuestion, lblLife, lblCorrect
txtLives, txtCorrect

and the code

Code:
Public Class frmMain

    Private Questions As New List(Of List(Of String))
    Private RandomIndex As List(Of Integer)
    Private RunningIndex As Integer = 0
    Private totalCorrect As Integer
    Private totalLife As Integer = 3

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        GenerateQuestion(RandomIndex(RunningIndex))
        shuffle()
        btnStart.Enabled = False
        btnRetry.Enabled = True
    End Sub

    Private Sub shuffle()
        Dim nListOfLocation As New List(Of Point)

        With nListOfLocation
            .Add(btnCorrect.Location)
            .Add(btnWrong1.Location)
            .Add(btnWrong2.Location)
            .Add(btnWrong3.Location)
        End With

        Dim ShuffledList As List(Of Integer) = GenerateUnique(4, 1, 4)

        btnCorrect.Location = nListOfLocation(ShuffledList(0) - 1)
        btnWrong1.Location = nListOfLocation(ShuffledList(1) - 1)
        btnWrong2.Location = nListOfLocation(ShuffledList(2) - 1)
        btnWrong3.Location = nListOfLocation(ShuffledList(3) - 1)
    End Sub

    Private Sub GenerateQuestion(ByVal nRandomIndex As Integer)
        Dim myQuestions As List(Of String) = Questions(nRandomIndex - 1)

        lblQuestion.Text = myQuestions(0)
        btnCorrect.Text = myQuestions(1)
        btnWrong1.Text = myQuestions(2)
        btnWrong2.Text = myQuestions(3)
        btnWrong3.Text = myQuestions(4)

        RunningIndex += 1
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddQuestionChoice("Question1", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question2", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question3", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question4", "Correct", "Wrong1", "Wrong2", "Wrong3")
        AddQuestionChoice("Question5", "Correct", "Wrong1", "Wrong2", "Wrong3")

        retry()
        btnRetry.Enabled = False
    End Sub

    Private Sub AddQuestionChoice(ByVal nQuestion As String, ByVal nCorrect As String, ByVal nWrong1 As String, ByVal nWrong2 As String, ByVal nWrong3 As String)
        Dim QuestionChoice As New List(Of String)

        With QuestionChoice
            .Add(nQuestion)
            .Add(nCorrect)
            .Add(nWrong1)
            .Add(nWrong2)
            .Add(nWrong3)
        End With

        Questions.Add(QuestionChoice)
    End Sub

    Public Function GenerateUnique(ByVal LoopCount As Integer, ByVal rMin As Integer, ByVal rMax As Integer) As List(Of Integer)
        Dim holder As New HashSet(Of Integer)
        Dim rand As New Random

        Do
            holder.Add(rand.Next(rMin, rMax + 1))
        Loop Until holder.Count = LoopCount

        Return holder.ToList
    End Function

    Private Sub btnRetry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetry.Click
        retry()
    End Sub

    Private Sub retry()
        Panel1.Enabled = True
        btnStart.Enabled = True
        btnRetry.Enabled = False
        lblQuestion.Text = Nothing

        RunningIndex = 0
        totalCorrect = 0
        totalLife = 3

        txtCorrect.Text = totalCorrect
        txtLives.Text = totalLife

        RandomIndex = GenerateUnique(Questions.Count, 1, Questions.Count)
    End Sub

    Private Sub btnCorrect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCorrect.Click
        If RunningIndex < Questions.Count Then
            GenerateQuestion(RandomIndex(RunningIndex))
            shuffle()
            totalCorrect += 1
            txtCorrect.Text = totalCorrect
        ElseIf RunningIndex = Questions.Count Then
            totalCorrect += 1
            txtCorrect.Text = totalCorrect

            RunningIndex += 1 ' append running index ' this is the last question
        End If
    End Sub

    Private Sub btnWrong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrong1.Click, btnWrong2.Click, btnWrong3.Click
        If RunningIndex < Questions.Count Then
            If totalLife <= 1 Then
                totalLife = totalLife - 1
                Panel1.Enabled = False
                MsgBox("game over")
            Else
                GenerateQuestion(RandomIndex(RunningIndex))
                shuffle()
                totalLife = totalLife - 1
            End If
        ElseIf RunningIndex = Questions.Count Then
            totalLife = totalLife - 1
            RunningIndex += 1  ' append running index ' this is the last question
        End If

        txtLives.Text = totalLife
    End Sub
End Class

palitan mo nalang yung form main load, di ko na ni arrange, kakain muna ako. lol. gutom na. if you would like to have an easy, medium, hard, gawa ka nalang ng new list, clear mo yung Questions tapos AddQuestionChoice nalang.

Random Question with Random Answers (ipag papalit nya ang location ng choices, kahit saan mo ilagay yung mga buttons), yung AddQuestionChoice lang kelangan mo galawin.


nice of you to take time and effort to contribute bro,

generic list is the way pag walang database,
or he could save it sa xml para di hardcoded ang questions then load sa "Questions" list

anyways he can always REFINE/REFACTOR codes for efficiency and readability if given the luxury of time.

@cyrilkun somebody took time and effort to do it for you, the least you can do is to study the code and learn from it
 
nice of you to take time and effort to contribute bro,

generic list is the way pag walang database,
or he could save it sa xml para di hardcoded ang questions then load sa "Questions" list

anyways he can always REFINE/REFACTOR codes for efficiency and readability if given the luxury of time.

@cyrilkun somebody took time and effort to do it for you, the least you can do is to study the code and learn from it

thank you ts.

he could update the codes if he'd like. minsan ko lang din kasi nagamit ang xml, yung pagawa ng rdlc file for printing. but anyway, the code works, tsaka yung frmLoad lang ang kailangan nya palitan.

cleaning the code is a different story, i also have work na kailangan tapusin...

gustong gusto ko tong thread mo ts... dito lang ako nakatambay...
 
sinu po may alam ng sql server add edit delete ng listview tnx.

PAGE 1 po...
page 1 lang

access ang nandun, just change the connection string para sa sql server and boom! you are done

pag di kabisado ang connection string ano gagawin?

punta lang dito
http://www.connectionstrings.com/


PS: you dont ADD/EDIT/DELETE Listviews, you do that to the underlying database

awts, nasenay na yata akow mag english mge brow...
 
Last edited:
from Craig Johnson

mas nauna naman kesa sakin
sa vb2 ako nag start

TRS-80 - wrote my first BASIC goto loop, nearly died of happiness.

Atari 800XL - AtariBASIC, my first computer, used it until it broke, got another one. (Peek(53279))

Atari 130XE - TurboBASIC, long live the ramdisk!

QBASIC (thanks Screen 12)

VB 1.0 - Bought it the day it came out.

VB 2.0 - Speedier!

VB 3.0 - DAO DAO DAO! And Thanks Dan Appleman!!!

VB 4.0 - In a Class all its own. Let the VBX vs OCX wars begin. Somehow got on the VB4 beta (Asked for the "CallByName" function - VB team listened!)

VB 5.0 - "Yes boss, it runs on Windows NT!" Went to Redmond to help write exam questions. Ah the seafood!

VB 6.0 - Bread and butter!

VB.NET 2003 - Sucketh a mighty suck.

VB8 - Generic goodness.

VB9 - What's a lambda expression? Ah yeah ok that's freaking awesome.

VB10 - Multi-statement lambdas make me smile.

VB11 - VB dogfooding to a new level. And I can barely sleep waiting for the Async CTP.

I will always be a VB developer and I'm proud of it! Thank you oh geniuses that continue to make this language better and better.

Async ang isa sa magandang mangyayari sa VB, nxt yng Roslyn
 
Last edited:
paano ko po ba malalaman kung null value yung nasa picture ng mysql ko po ?


kasi po nag eerror sya pag wala syang nakitang value dun sa table ko po , ito error :

unable to cast object of type 'system.dbnull' to type 'system.byte[]'

parang yung bold po i momodify ko eh ,, kaso di po ako marunong mag modify .. :(

ito po code :

Code:
Private Sub uploadpic()

        Dim SQLCmd As New MySqlCommand("SELECT Picture FROM Student_information WHERE S_I_D = ('" & ListView1.Items(ListView1.FocusedItem.Index).SubItems(0).Text & "') ", dbcon)

        dbcon.Open()

        [B]Dim pictureData As Byte() = DirectCast(SQLCmd.ExecuteScalar(), Byte())[/B]

        dbcon.Close()

        Dim picture As Image = Nothing

        'Create a stream in memory containing the bytes that comprise the image.
        Using stream As New IO.MemoryStream(pictureData)
            'Read the stream and create an Image object from the data.
            PictureBox4.Image = Image.FromStream(stream)
        End Using


    End Sub
 
Last edited:
ok na ata sir , gumagana naman sa kagustuhan ko :noidea:

paki tingin na lang po kung tama sya ,

di ko po alam kasi concatenate eh .. :slap:

Code:
Private Sub uploadpic()
        Dim connection As New MySqlConnection("Server=localhost;port=3306;Database=afgbmts_database;Uid=root;Pwd=root")
        Dim command As New MySqlCommand("SELECT Picture FROM student_information WHERE S_I_D = 0000012", connection)
        Dim pictureData As Byte()
        connection.Open()

        Dim Result As Object = command.ExecuteScalar
        If IsDBNull(Result) Then
            MsgBox("happy")
            PictureBox1.Image = Nothing
        Else
            pictureData = DirectCast(command.ExecuteScalar(), Byte())
            Using stream As New IO.MemoryStream(pictureData)
                'Read the stream and create an Image object from the data.
                PictureBox1.Image = Image.FromStream(stream)
            End Using
        End If
        connection.Close()
    End Sub
 
pahelp naman po ng auto alt key presser, gamitin ko lang para sa games sa vb.net po
 
pahelp naman po ng auto alt key presser, gamitin ko lang para sa games sa vb.net po

Code:
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Const KEYEVENTF_KEYUP = &H2     'Key UP

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        keybd_event(&H12, 0, 0, 0) ' ALT key
    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        keybd_event(&H12, 0, KEYEVENTF_KEYUP, 0) ' ALT key
    End Sub

lagay ka lang dalawang button, namely: btnStart, btnStop or pwede na start lang, tapos para ma stop, press mo lang ang right alt.

for reference of virtual key code: click here
 
you are solving your problem in bits and pieces kasi kaya mas time consuming yan

my solution is to have a
quiz type application na iisang form lang,
nagbabago ng question kada click,
may timer pa kung gusto mo
nakikita mo yung lives sa taas
at nasa database yung questions (thats why i asked you to do it)

maski isang form pwede na dyan at ilang dipa ng code
ma re-use mo pa yung ibang codes mo

anyways im not questioning your creativity nor your code,
i just have a different approach to the problem

hhe :)

salamat pu okay I'll try it, lalu na sa mag new project ku na quiz rin ang gagawin.. hhe

:)

thank you for helping me.. hhe

I am just really stressed and nawawala aku sa concentration lalu na pag malapit na yung pre-final presentationn.. :)

I will try yung sinabe mu and pati rin yung code ni maskio..

but for now, ang magagawa ku kanya... hhe.. but if I have enough time left.. para mamaya I will try it..

by the way sir,, if you know where can I download Microsoft visual studio 2010 na hindi trial help me for it.. dun aku makakaconnect sa database as I suspect.. :)

-Certified NewBie
-Certified Otaku
 
Back
Top Bottom