首页 \ 问答 \ 从VB.net中的模块中读取单选按钮(Reading radio buttons from module in VB.net)

从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?

更新时间:2022-04-08 13:04

最满意答案

问题已经解决了。 必须首先更改模块中单选按钮的顺序,然后将其更改为布尔值。 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.
  • 将这些控件放在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 ...
  • 唯一的方法是创建一个名为checked的属性,该属性包装一个复选框控件,该控件是表单类的成员。 就像是: Public Property checked() As Boolean Get return myCheckbox.Checked End Get Set(ByVal Value As Integer) myCheckbox.Checked = value End Set End Property 尽管如此,这样做并不会让你失望。 它实 ...
  • 您可以在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 ...
  • Module在技术上并不意味着静态类。 VB.net中的静态(关于函数)是Shared ,并且没有Shared Class 。 我认为你想要的是一个带有静态/共享函数的密封/抽象/不可继承的类(你可以在没有父类实例的情况下调用函数,但是你仍然需要引用父类。调用函数)。 如果是这种情况,那么执行类似以下的操作: Public NotInheritable Class HelperA Public Shared Function FunctionA() as Boolean Return ...
  • 您可以将常量放在public static class如下所示: public static class MyConnectionStringConstants { public const string strDatabase = "****"; public const string strUserID = "****"; public const string strPssWd = "****"; } 要使用它,您需要像这样引用常量: string strAccessConn ...

相关文章

更多

最新问答

更多
  • 在javascript中创建类以创建对象并在Java中创建类和对象之间的区别(Difference between creating a class in javascript to create an object and creating an class and object in Java)
  • Facebook API:将身份验证详细信息从Javascript SDK发送到PHP SDK(Facebook API: Send authentication detail from Javascript SDK to PHP SDK)
  • 如何停止队列动画jquery?(How can I stop queue animation jquery?)
  • 使用C#的井字游戏中的人工智能(Artificial Intelligence in Tic-Tac-Toe using C#)
  • 多少流量可以共享虚拟主机(对于Python Django站点)支持?(How Much Traffic Can Shared Web Hosting (for a Python Django site) support?)
  • 带有CIFilters的CAShapeLayer(CAShapeLayer with CIFilters)
  • 如何在Angular 2中读取JSON #text(How to read in Angular 2 the JSON #text)
  • 如何在xml中读取自闭标签的属性?(How to read self closing tag's attribute in xml?)
  • 无法使用http put将图像上传到亚马逊S3(Cannot upload image to amazon s3 using http put)
  • 文件结束无限循环(end of file infinite while-loop)
  • 在cpp的模板(template in cpp)
  • 在构建库时,clang和clang ++有什么区别?(What's the difference between clang and clang++ when building a library?)
  • ng类中的表达式(expression inside ng-class)
  • 在PHP中获取随机布尔值true / false(Get random boolean true/false in PHP)
  • 管道的高效分块用于严格的字节串(Efficient chunking of conduit for strict bytestring)
  • Python ternary_operator(如果其他标志做了其他操作,则执行其他操作)(Python ternary_operator (do-somthing if flag else do-another))
  • Sencha Touch面具发布(Sencha Touch mask ondisclosure)
  • 验证脚本上的通知[重复](Notices on validation script [duplicate])
  • 朋友功能(friend function)
  • 基于角坐标平移和变换平面几何(Translate and transform plane geometry based on corner coordinates)
  • Rails:'如果在本地运行'条件javascript标记包括(Rails: 'if running locally' conditional javascript tag include)
  • 解压文件(Unzipping files)
  • 使用ui-router以角度加载变量状态(loading in variable states with ui-router in angular)
  • 创建Azure云服务需要多长时间?(how long does it take to create an Azure Cloud Service? How to view log information?)
  • 指向整数的指针数组(Array of pointers to integers)
  • Laravel服务提供商没有看到我的包的主要类(Laravel service provider does not see the main class of my package)
  • 这个关于VSS / RSS / PSS / USS的解释是否准确?(Is this explanation about VSS/RSS/PSS/USS accurate?)
  • 在Django-Admin中通过row-id排序显示项目(Ordering the display items by row-id in Django-Admin)
  • 如何使用cythonize启用`--embed`?(How to enable `--embed` with cythonize?)
  • 用于将文本多行设置的Excel脚本(Excel script for ereasing text multiple rows)