从VB.net中的模块中读取单选按钮(Reading radio buttons from module in VB.net)
我创建了这个模块,我知道结构学生和老师的学生和老师都是字符串(这些存储为我的单选按钮),但是当我将这些保存到文件中时,这可以通过保存真或假来实现id和密码的值。 但是,我无法从另一个班级读取单选按钮。
这是我的模块类
Imports System.IO Module user_info_mod Structure user <VBFixedString(3)> Dim name As String <VBFixedString(3)> Dim password As String <VBFixedString(7)> Dim student As String <VBFixedString(3)> Dim teacher As String End Structure Public newuser As user Public userNumber As Integer = FreeFile() Public userrecordNumber As Integer = 1 Public Sub setRecordNumber() Dim n As Byte = 0 FileOpen(userNumber, "D:\users.dat", OpenMode.Random, OpenAccess.Read) While Not EOF(userNumber) n = n + 1 'increments the record number of the user FileGet(userNumber, newuser, n) End While userrecordNumber = n FileClose(userNumber) End Sub End Module
这是我试图读取主文件中的单选按钮(newuser.student = True)
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click Dim password As String password = txtPassword.Text Dim username As String username = txtUsername.Text FileOpen(userNumber, "D:\users.dat", OpenMode.Random, OpenAccess.Read) FileGet(userNumber, newuser, userrecordNumber) If password = newuser.password And username = newuser.name And newuser.student = True Then MsgBox("ID Accepted") Dim frmNew As New Student_selection frmNew.ShowDialog() FileClose(userNumber) Else FileClose(userNumber) MsgBox("ID is not accepted") End If End Sub
如果我要在模块中将字符串更改为布尔值,这不能使我在模块中设置记录号时保存用户的文件,那么解决此问题的正确方法是什么?
i have created this module and i know that the student and teacher in the structure student and teacher are put as string (these are stored as my radio buttons), but when i save these to the file, this works by saving a true or false value for the id and password. however, i am unable to read the radio buttons from another class.
this is my module class
Imports System.IO Module user_info_mod Structure user <VBFixedString(3)> Dim name As String <VBFixedString(3)> Dim password As String <VBFixedString(7)> Dim student As String <VBFixedString(3)> Dim teacher As String End Structure Public newuser As user Public userNumber As Integer = FreeFile() Public userrecordNumber As Integer = 1 Public Sub setRecordNumber() Dim n As Byte = 0 FileOpen(userNumber, "D:\users.dat", OpenMode.Random, OpenAccess.Read) While Not EOF(userNumber) n = n + 1 'increments the record number of the user FileGet(userNumber, newuser, n) End While userrecordNumber = n FileClose(userNumber) End Sub End Module
this is where i am trying to read the radio button in the main file ( newuser.student=True)
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click Dim password As String password = txtPassword.Text Dim username As String username = txtUsername.Text FileOpen(userNumber, "D:\users.dat", OpenMode.Random, OpenAccess.Read) FileGet(userNumber, newuser, userrecordNumber) If password = newuser.password And username = newuser.name And newuser.student = True Then MsgBox("ID Accepted") Dim frmNew As New Student_selection frmNew.ShowDialog() FileClose(userNumber) Else FileClose(userNumber) MsgBox("ID is not accepted") End If End Sub
if i am to change the string to boolean in the module, this is not enabling me to save a user's file when setting the record number within the module, so what is the correct way in order to solve this problem?
最满意答案
问题已经解决了。 必须首先更改模块中单选按钮的顺序,然后将其更改为布尔值。
Dim student As Boolean
problem has been solved. The order of the radio buttons within the module had to be changed first, and then changed to a Boolean.
Dim student As Boolean
相关问答
更多-
问题已经解决了。 必须首先更改模块中单选按钮的顺序,然后将其更改为布尔值。 Dim student As Boolean problem has been solved. The order of the radio buttons within the module had to be changed first, and then changed to a Boolean. Dim student As Boolean
-
它们被称为Class文件。 右键单击要添加类的解决方案或文件夹,然后选择“ Add new item然后从窗口中选择“ Class 。 They are called Class files. Right-click on your solution, or folder you wish to add the class and choose Add new item then from the window choose Class.
-
隐藏VB.net中的控件组(Hide Group of controls in VB.net)[2022-06-15]
将这些控件放在GroupBox2中并将其visible属性设置为false。 当你的应用程序运行时,GroupBox不可见,所以我使用一个标题为“Show GroupBox2”的按钮,所以当我点击按钮时,GroupBox2将可见: 使GroupBox可见的源代码 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click GroupBox ... -
您必须为DataGridView创建自己的单元格和列。 它有点棘手,但在这里你有MSDN的所有步骤: http://msdn.microsoft.com/en-us/library/aa730882(v=vs.80).aspx You have to create your own cell and column for the DataGridView. Its a little bit tricky, but here you have all the steps from MSDN: http://m ...
-
“Main()”是一个功能。 并且您声明了一个局部变量“sConnection”。 您的表格是另一个类。 类只能访问其成员,全局成员或全局静态成员(或某些朋友方案,如C ++)。 从“Main”中取出声明,在表单范围内声明或将其声明为全局变量,表单可以访问。 或者将您的连接字符串放在配置文件中并从中读取。 (在以后的时间点很容易配置。) The "Main()" is a function. And you declared a local variable "sConnection". Your Form ...
-
VB.net - 元素参考(VB.net - Element Reference)[2022-05-13]
唯一的方法是创建一个名为checked的属性,该属性包装一个复选框控件,该控件是表单类的成员。 就像是: Public Property checked() As Boolean Get return myCheckbox.Checked End Get Set(ByVal Value As Integer) myCheckbox.Checked = value End Set End Property 尽管如此,这样做并不会让你失望。 它实 ... -
使用单选按钮,highcharts,vb.net从服务器获取数据(get data from the server using radio buttons, highcharts, vb.net)[2022-10-14]
您可以在change处理程序中进行一次AJAX调用(使用jQuery的get ,例如,因为它似乎正在使用它)以获取必要的数据。 在服务器端,您将返回带有数组或数组的JSON,并根据需要分配它们。 由于您使用的是VB.NET,我猜您正在使用ASP.NET,因此请查看他们的文档。 You could make one AJAX call (using jQuery's get for example as it seems you are using it) inside the change handler ... -
SP_TestCom.ReceivedBytesThreshold = 10 这是一个相当麻烦的财产。 是的,26是一个神奇的数字。 它是Ctrl + Z,默认的文件结束字符。 日期回到石器时代,遗憾的是它无法改变。 这对您的DataReceived事件处理程序很重要,它会激发一个额外的时间来告诉您有关Eof的信息。 这搞砸了你的逻辑,BytesToRead的价值是不可预测的。 你必须快速离开,像这样: Private Sub SP_TestCom_DataReceived(ByVal sender As ...
-
VB.Net模块行为(VB.Net module behavior)[2022-06-25]
Module在技术上并不意味着静态类。 VB.net中的静态(关于函数)是Shared ,并且没有Shared Class 。 我认为你想要的是一个带有静态/共享函数的密封/抽象/不可继承的类(你可以在没有父类实例的情况下调用函数,但是你仍然需要引用父类。调用函数)。 如果是这种情况,那么执行类似以下的操作: Public NotInheritable Class HelperA Public Shared Function FunctionA() as Boolean Return ... -
将VB.net模块转换为C#(convert VB.net Module to C#)[2023-03-05]
您可以将常量放在public static class如下所示: public static class MyConnectionStringConstants { public const string strDatabase = "****"; public const string strUserID = "****"; public const string strPssWd = "****"; } 要使用它,您需要像这样引用常量: string strAccessConn ...